Counting rows in AutoFilter mode

  • Thread starter Thread starter Rob Pauly
  • Start date Start date
R

Rob Pauly

I just want to count the number of records/rows who match a value
specified with AutoFilter.

I already tried this:

Selection.AutoFilter Field:=3, Criteria1:="TEST"
Range("c1").Select
Range(Selection, Selection.End(xlDown)).Select
intTest = Selection.Rows.Count

but this wil give te wrong result.

please, can anyone give me an answer
 
Try this.
Selection.AutoFilter Field:=3, Criteria1:="TEST"
MsgBox selection.SpecialCells(xlCellTypeVisible).Count
 
This only works if you restrict the selection to one column

Activesheet.Autofilter.Range.Columns(1).SpecialCells(xlVisible).count -1

subtract 1 to remove the count of the header row.
 
Back
Top