Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default How to get the count of filtered rows after applying autofilter?

Hi,

I've written a macro to autofilter on a particular column of a worksheet.
Now i need to get the count of filtered rows (no. of visible records). I'm
not sure how to use the 'Count' property of autofilter. I've written a code
block to do this work for me which consumes a lot of time.

ActiveSheet.Range("$A$1:$AX$5000").AutoFilter Field:=FilterColumn2,
Criteria1:=FilterValue2, Operator:=xlFilterValues

TotalNumber = 0

For j = 2 To 5000
If Cells(j, 1) < "" Then
If Cells(j, 1).EntireRow.Hidden = False Then
TotalNumber = TotalNumber + 1
End If
Else
Exit For
End If
Next

Is there a way to get the count by using count property rather than using
the above code block?

Many Thanks,
Vinoth
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default How to get the count of filtered rows after applying autofilter?


One approach from Debra Dalgleish here...
http://www.contextures.on.ca/xlautofilter02.html#Count
--
Jim Cone
Portland, Oregon USA



"Vinoth"

wrote in message
...
Hi,
I've written a macro to autofilter on a particular column of a worksheet.
Now i need to get the count of filtered rows (no. of visible records). I'm
not sure how to use the 'Count' property of autofilter. I've written a code
block to do this work for me which consumes a lot of time.

ActiveSheet.Range("$A$1:$AX$5000").AutoFilter Field:=FilterColumn2,
Criteria1:=FilterValue2, Operator:=xlFilterValues

TotalNumber = 0

For j = 2 To 5000
If Cells(j, 1) < "" Then
If Cells(j, 1).EntireRow.Hidden = False Then
TotalNumber = TotalNumber + 1
End If
Else
Exit For
End If
Next

Is there a way to get the count by using count property rather than using
the above code block?

Many Thanks,
Vinoth
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 199
Default How to get the count of filtered rows after applying autofilter?

Looking at your code, I guess you want the count of rows from the top
continuously not hidden and not blank. for example like below

row1 -- shown and not blank
rpw2 -- shown and not blank
row3 -- shown and not blank
row4 -- hidden
row5 -- shown
row6 -- hidden
row7 -- shown

The answer you want to get is 2.
and the data like below

row1 -- shown and blank
rpw2 -- hidden and blank
row3 -- shown and not blank
row4 -- hidden
row5 -- shown
row6 -- hidden
row7 -- shown

The answer you want to get is 0.

Is this what you want?

Keiji

Vinoth wrote:
Hi,

I've written a macro to autofilter on a particular column of a worksheet.
Now i need to get the count of filtered rows (no. of visible records). I'm
not sure how to use the 'Count' property of autofilter. I've written a code
block to do this work for me which consumes a lot of time.

ActiveSheet.Range("$A$1:$AX$5000").AutoFilter Field:=FilterColumn2,
Criteria1:=FilterValue2, Operator:=xlFilterValues

TotalNumber = 0

For j = 2 To 5000
If Cells(j, 1) < "" Then
If Cells(j, 1).EntireRow.Hidden = False Then
TotalNumber = TotalNumber + 1
End If
Else
Exit For
End If
Next

Is there a way to get the count by using count property rather than using
the above code block?

Many Thanks,
Vinoth

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I count rows in a filtered list when using AutoFilter? chiefcook Excel Worksheet Functions 6 November 10th 08 09:21 AM
Autofilter and count on filtered data gr8posts Excel Worksheet Functions 7 October 19th 07 09:17 PM
How can I make autofilter show the filtered number of rows bsell123 Excel Worksheet Functions 1 October 28th 04 06:12 PM
Finding row count and filtered rows returned by Autofilter Joseph Uher Excel Programming 0 September 20th 03 08:49 PM
How To Count Rows Displayed After Applying AutoFilter Steve[_32_] Excel Programming 2 August 12th 03 02:45 PM


All times are GMT +1. The time now is 02:43 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"