Stop searching. Start learning and developing your excel skills.
Macro
VBA
Formula
Function
Shortcut
Tricks

» » VBA To Count Total Rows or Visible Rows

VBA To Count Total Rows or Visible Rows

June 03, 2017 |
This is also related to below queries:
  1. excel vba count visible rows in table
  2. specialcells xlcelltypevisible rows count
  3. vba loop through visible rows
  4. specialcells(xlcelltypevisible).rows.count not working
  5. countif visible cells vba
  6. get row number of filtered row vba
The Code:

Dim i As Long
i = Cells(Rows.Count, "A").End(xlUp).Row
''' VBA To count Total Rows in Excel
Dim j As Long
j = Sheets("Sheet1").AutoFilter.Range.Columns(1).SpecialCells(xlCellTypeVisible).Cells.Count - 1
'''VBA to count number of visible rows after autofilter row


Note:
  1. Take column A or first column to count as first column is normally clean. It does not contain any blank rows
  2. For Autofilter, we need to minus 1 as header is also counted in the formula. Minus 1 will remove header. If you need to count the header then no need to Minus 1

No comments:

Post a Comment