Link to home
Start Free TrialLog in
Avatar of Eduardo Fuerte
Eduardo FuerteFlag for Brazil

asked on

Could you point a way the obtain the total line filtered at an Excel sheet?

Hi Experts

Could you point a way the obtain the total line filtered at an Excel sheet?

Accordingly to
User generated image
I need to obtain the number of filtered lines.

Thanks in advance

Avatar of Martin Liss
Martin Liss
Flag of United States of America image

intTotCount = Activesheet.AutoFilter.Range.Columns(1).SpecialCells(xlCellTypeVisible).Cells.Count - 1

You might need to remove the - 1
The SUBTOTAL function has a COUNT/COUNTA and SUM options.

=SUBTOTAL(2,Range)  will count the visible numeric cells in the range, equivalent to COUNT
=SUBTOTAL(3,Range)  will count the visible non blank cells in the range, equivalent to COUNTA
=SUBTOTAL(9,Range)  will sum the visible non blank cells in the range 
Avatar of Eduardo Fuerte

ASKER

So, I have to develop a program to do that?

Could you give me a step by step on doing it?
ASKER CERTIFIED SOLUTION
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
So, I have to develop a program to do that?
Try with formulas 1st.
@Martin

Followed your instructions...

 User generated image
Debbuging:
User generated image
774 lines filtered....  

Is it correctly done?
Seriously, scratch VBA, turn your data into a table, display the total row and use the SUBTOTAL formula.

See the attached sample workbook.
test.xlsx

User generated imageUser generated imageUser generated image
It looks correct. What do you want to do with intTotCount?
My purpose is to show how many lines represents "queries"  that needs to be tested at DB- by using the data contained at the cells I could find at another place the queries.

The filtered lines are just for those that have the columns of  scheduled dates (not visible at the picture) filled....
I'm sorry but I don't understand. Can you show me a picture of how you plan to use the total?
Ok.

Imagine the complete sheet (without filter) is a complete test plan, so, each row is a test.

But some tests are not applicable, so the remain tests are the ones filtered.

I need to know how many tests remains to be tested.

Just it.
Do you want to show the total on a worksheet somewhere? If so, where?
Not necessary,  Just to obtain the total to have this information,
Thank you for so adequated solution!
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 Most Valuable Expert (MVE) 2015, 2017
              Experts Exchange Distinguished Expert in Excel 2018
              Experts Exchange Top Expert Visual Basic Classic 2012 to 2020
              Experts Exchange Top Expert VBA 2018 to 2020