codecaine

Display visible row count from sheet1 in sheet2

May 5th, 2021 (edited)
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Function getVisibleRowCount(rng As Range) As Long
  2. 'return the number of visible rows from a range
  3.    Dim cellItem As Range
  4.     Dim count As Long
  5.     count = 0
  6.     For Each cellItem In rng.SpecialCells(xlCellTypeVisible).Rows
  7.         count = count + 1
  8.     Next cellItem
  9.     getVisibleRowCount = count
  10. End Function
  11.  
  12. Sub display_row_count()
  13. 'Display visible row count from sheet1 at cell A1 Current Region and display it in Sheet 2
  14. Sheet2.Range("A1").Value = "Sheet 1 Row Count: " & getVisibleRowCount(Sheet1.Range("A1").CurrentRegion)
  15. End Sub
  16.  
Add Comment
Please, Sign In to add comment