Public Function CountDataRows() As Long 'Counts the number of non-blank cells from a START cell range. Loops through the range until empty cell is found. Returns the total number of rows that contain data within the 'specified range/column. Note: Is dependant on each row having a value. Dim wks As worksheet Dim wkb As Workbook Dim rng As Range Dim Counter As Long Set wkb = ActiveWorkbook Set wks = wkb.Sheets("Test") Set rng = wks.Range("testrow") With wks Counter = 0 Do Until wks.Range("testrow").Offset(Counter, 0) Is Not Empty Counter = Counter + 1 Loop End With CountDataRows = Counter End Function
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
27 Experts available now in Live!