Getting an column Average, with AutoFilters applied.

What would a formula look like, if I try to average a datatable that has 2 or 3 autofilters applied to it?  Whenever I apply the filters and put in =AVERAGE(range1) it includes the hidden cells in the result?  I select the header and do a Ctrl+down, then offset activecell (1,0).Select to get to bottom of column.  Then I want to add the formula.  Any idea how this formula should look or be so it does not include those filtered out cells?  Please advise and thanks. -R-
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

Martin LissOlder than dirtCommented:
=SUBTOTAL(1, range1)

The "1" represents AVERAGE. In the formula bar if you delete the "1" a list of other functions will appear. "101" (in this case) would also ignore manually hidden rows.

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
RWayneHAuthor Commented:
Thanks this worked... can I ask another minor question?

I use:
    ActiveCell.Offset(1, 0).Select  'one down

To get to the bottom of a filtered set, however if there are filtered out rows, it does not give me the right cell.  Is there a way to do an xlup to get the cell under the filtered dataset?
Martin LissOlder than dirtCommented:
I'm not sure what you are asking. If you had 1, 2, 3, ... 10 in column D1, Q2, D3..., D10, and only 3, 4 , and 5 were showing, which row would you want to select?

If you want to select the last visible cell then this works.

Cells(Range("D1048576").End(xlUp).Row, "D").Activate
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

RWayneHAuthor Commented:
The filter shows 3,4,5.  I would like row 11.  6,7,8,9, and 10 are hidden.  The code I am using highlights/goes to row 6.  I was wondering if there is an easier way to get to row 11 using xlup instead of xldown?
Martin LissOlder than dirtCommented:
This uses the row portion of autofilter range address.

Range(Split(ActiveSheet.AutoFilter.Range.Address, ":")(1)).Offset(1, 0).Activate
RWayneHAuthor Commented:
Yup that's it.... now to get it to the proper column.....   can I tell that line of code to Activate a specific column? like column D?
Thanks for helping with the extended question...   I know that you did not have too and probably should have been its own separate question. .  -R-
Martin LissOlder than dirtCommented:
It's not too late to do that:)
Martin LissOlder than dirtCommented:
That's OK, never mind.

Range("D" & ActiveSheet.AutoFilter.Range.Rows.Count + 1).Activate
RWayneHAuthor Commented:
RWayneHAuthor Commented:
Martin LissOlder than dirtCommented:
You're welcome and I'm glad I was able to help.

If you expand the “Full Biography” section of my profile you'll find links to some articles I've written that may interest you.

Marty - Microsoft MVP 2009 to 2017
              Experts Exchange MVE 2015
              Experts Exchange Top Expert Visual Basic Classic 2012 to 2017
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
Microsoft Excel

From novice to tech pro — start learning today.