Counting rows in AutoFilter mode

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
 
D

Don Guillett

Try this.
Selection.AutoFilter Field:=3, Criteria1:="TEST"
MsgBox selection.SpecialCells(xlCellTypeVisible).Count
 
T

Tom Ogilvy

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top