ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Counting rows in AutoFilter mode (https://www.excelbanter.com/excel-programming/278465-counting-rows-autofilter-mode.html)

Rob Pauly

Counting rows in AutoFilter mode
 
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

Don Guillett[_4_]

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

"Rob Pauly" wrote in message
m...
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




Tom Ogilvy

Counting rows in AutoFilter mode
 
This only works if you restrict the selection to one column

Activesheet.Autofilter.Range.Columns(1).SpecialCel ls(xlVisible).count -1

subtract 1 to remove the count of the header row.

--
Regards,
Tom Ogilvy


"Don Guillett" wrote in message
...
Try this.
Selection.AutoFilter Field:=3, Criteria1:="TEST"
MsgBox selection.SpecialCells(xlCellTypeVisible).Count

"Rob Pauly" wrote in message
m...
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







All times are GMT +1. The time now is 01:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com