Count number of rows populated by an autofilter in excel.

team       subteam       user             priority
T              t2                       u1                1
T              t2                       u2                1
T              t2                       u2                1
T                 t2                       u2                1
T             t2                       u1                1
T            t2                       u1            1
T            t2                       u2                1
T             t2                       u1                1
T            t2                       u1                1
T              t2                       u2                1

consider above data I get by applying an autofilter for priority 1 for users u1,u2 belonging to team 2, what I need is a count of the populated rows in column ''priority'' in Excel VBA code. I tried using Subtotal function but I don't want the count generated via subtotal function.
Saurabh kAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rob HensonFinance AnalystCommented:
Why do you not want to use Subtotal function?

The syntax for subtotal is:


The # parameter has numerous options:
Function_num                   Function_num       Function
(includes hidden values)      (ignores hidden values)      
1                                    101                        AVERAGE
2                                    102                        COUNT
3                                    103                        COUNTA
4                                    104                        MAX
5                                    105                        MIN
6                                    106                        PRODUCT
7                                    107                        STDEV
8                                    108                        STDEVP
9                                    109                        SUM
10                                    110                        VAR
11                                    111                        VARP

Copied from the online help:

## If there are other subtotals within ref1, ref2,… (or nested subtotals), these nested subtotals are ignored to avoid double counting.

## For the function_num constants from 1 to 11, the SUBTOTAL function includes the values of rows hidden by the Hide Rows command under the Hide & Unhide submenu of the Format command in the Cells group on the Home tab in the Excel desktop application. Use these constants when you want to subtotal hidden and nonhidden numbers in a list. For the function_Num constants from 101 to 111, the SUBTOTAL function ignores values of rows hidden by the Hide Rows command. Use these constants when you want to subtotal only nonhidden numbers in a list.

## The SUBTOTAL function ignores any rows that are not included in the result of a filter, no matter which function_num value you use.

## The SUBTOTAL function is designed for columns of data, or vertical ranges. It is not designed for rows of data, or horizontal ranges. For example, when you subtotal a horizontal range using a function_num of 101 or greater, such as SUBTOTAL(109,B2:G2), hiding a column does not affect the subtotal. But, hiding a row in a subtotal of a vertical range does affect the subtotal.

## If any of the references are 3-D references, SUBTOTAL returns the #VALUE! error value.

pls try
res  = Range("D1").End(xlDown).SpecialCells(xlCellTypeVisible).Rows.Count-1

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial

Open in new window

No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

-- Rgonzo1971 (https:#a42399734)
-- aikimark (https:#a42401959)
-- Rob Henson (https:#a42399731)

If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

Experts-Exchange Cleanup Volunteer
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.