Function getVisibleRowCount(rng As Range) As Long
'return the number of visible rows from a range
Dim cellItem As Range
Dim count As Long
count = 0
For Each cellItem In rng.SpecialCells(xlCellTypeVisible).Rows
count = count + 1
Next cellItem
getVisibleRowCount = count
End Function
Sub display_row_count()
'Display visible row count from sheet1 at cell A1 Current Region and display it in Sheet 2
Sheet2.Range("A1").Value = "Sheet 1 Row Count: " & getVisibleRowCount(Sheet1.Range("A1").CurrentRegion)
End Sub
Comments