hugoohta
asked on
Count the autofilter
Hi,
I need a VBA code that helps counting different categories in an autofilter.
Let's say in my sheet autofiltered I needed to copy all the rows that have
in their column E the word 'Commerce'.
What I am doing right now is recording a macro that selects from the autofilter
the filed 'Commerce' and copies the whole sheet from A:2 until I:65000
but this is completely unefficient. since I have to do this again and again for many many fields
and keeping in mind that my original doc has a lot of rows!
So basically, I need a code that overcomes the fact that my commerce field
is made up of: row 2,3,13,21,22,23,24,34,42,4 3
for instance and I want that code to return 10 rows rather than 43 in the count.
Thanks for the help
Listing.xls
I need a VBA code that helps counting different categories in an autofilter.
Let's say in my sheet autofiltered I needed to copy all the rows that have
in their column E the word 'Commerce'.
What I am doing right now is recording a macro that selects from the autofilter
the filed 'Commerce' and copies the whole sheet from A:2 until I:65000
but this is completely unefficient. since I have to do this again and again for many many fields
and keeping in mind that my original doc has a lot of rows!
So basically, I need a code that overcomes the fact that my commerce field
is made up of: row 2,3,13,21,22,23,24,34,42,4
for instance and I want that code to return 10 rows rather than 43 in the count.
Thanks for the help
Listing.xls
ASKER
What I am using right now is that code:
Sheets("autofiltered").Aut oFilterMod e = False
Sheets("autofiltered").Row s("1:1").A utoFilter
Sheets("autofiltered").Row s("1:1").A utoFilter Field:=5, Criteria1:="'Commerce' "
On Error Resume Next
Sheets("autofiltered").Ran ge("A1:I59 999").Copy Sheets("Sheet2").Range("A5 9999").End (xlUp).Off set(0, 0)
How can I designate the exact amount of rows I need to copy and paste in sheet2
Thanks
Sheets("autofiltered").Aut
Sheets("autofiltered").Row
Sheets("autofiltered").Row
On Error Resume Next
Sheets("autofiltered").Ran
How can I designate the exact amount of rows I need to copy and paste in sheet2
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
One way is to evaluate the SUBTOTAL function, calling the COUNTA function....
Dim VisRows as Long : VisRows = [SUBTOTAL(3, A:A)]
Regards,
Wayne