I’m looking for a VBA code which counts the number of rows which contains data.
I was looking in the forum and found
Any help would be great.
Unfortunately the code is not returning the correct number of rows
I was playing a bit around but never got the correct result
Sub countRows() Dim lngRowsProject As Long lngRowsProject = Columns("AG:AG").SpecialCells(xlVisible).Rows.Count ' returns me 21 (column AH has 21 rows, but column AG has just 2) lngRowsProject = Range("AG").CurrentRegion.Rows.Count ' returns me 43 (the total numbers of rows in the spreadsheet are 43) MsgBox "The number of rows is " & lngRowsProject End Sub
Does anyone know how to change the code that it’s just returning the number of rows in column AG???
Thanks a lot in advance!