' Check if sheet is empty If lastRow = 1 And IsEmpty(ws.Range("A1")) Then lastRow = 0 End If
MsgBox "Number of rows: " & rowCount End Sub Sub GetRowCount() Dim ws As Worksheet Dim lastRow As Long ' Set the worksheet Set ws = ThisWorkbook.Sheets("Sheet1") contar numero de filas en excel vba
' Find last row with data in column A On Error Resume Next lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row On Error GoTo 0 ' Check if sheet is empty If lastRow = 1 And IsEmpty(ws