This works for me especially in pivots table filtering when I want the count of cells with data on a filtered column. Reduce k
accordingly (k - 1)
if you have a header row for filtering:
k = Sheets("Sheet1").Range("$A:$A").SpecialCells(xlCellTypeVisible).SpecialCells(xlCellTypeConstants).Count