codecaine icon

Display visible row count from sheet1 in sheet2

codecaine | PRO | 05/05/21 06:06:42 PM UTC (Edited) | 0 ⭐ | 513 👁️ | Never ⏰ | []
VBScript |

550 B

|

None

|

0 👍

/

0 👎

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