SUBTOTAL in auto-filterered table

Stevenn

Active Member
Joined
Feb 8, 2012
Messages
259
Hi,

I've got a table with a lot of raw data which looks something like:

==
TypeID, Amount
--
1, 200
1, 300
1, 100
2, 400
2, 500
8, 300
==

and I want another table in another sheet in the same workbook with data like this:

==
TypeID, Amount
--
1, 600
2, 900
3, 0
4, 0
5, 0
6, 0
7, 0
8, 300
9, 0
==

How is this possible? In other words, how can I get the subtotal of a autofiltered list?
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Hi,

I've got a table with a lot of raw data which looks something like:

==
TypeID, Amount
--
1, 200
1, 300
1, 100
2, 400
2, 500
8, 300
==

and I want another table in another sheet in the same workbook with data like this:

==
TypeID, Amount
--
1, 600
2, 900
3, 0
4, 0
5, 0
6, 0
7, 0
8, 300
9, 0
==

How is this possible? In other words, how can I get the subtotal of a autofiltered list?
Try this...

Filtered (or unfiltered) data on sheet1:

Book1
AB
51200
61300
71100
82400
92500
108300
Sheet1

Summary sheet:

Book1
AB
51600
62900
730
840
950
1060
1170
128300
1390
Summary

This formula entered in B5 and copied down:

=SUMPRODUCT(SUBTOTAL(9,OFFSET(Sheet1!B$5,ROW(Sheet1!B$5:B$20)-ROW(Sheet1!B$5),0)),--(Sheet1!A$5:A$20=A5))
 
Upvote 0
It works :biggrin: Thank you. I thought I had to do some tricky VBA code.

I've tried to use it with tables, so I can use named columns, such as ROW(Table1) instead of Sheet1!B$5:B$20, but I will only get the result 0 no matter what I do. Is it not possible to use the code with the functions of tables?
 
Upvote 0
It works :biggrin: Thank you. I thought I had to do some tricky VBA code.

I've tried to use it with tables, so I can use named columns, such as ROW(Table1) instead of Sheet1!B$5:B$20, but I will only get the result 0 no matter what I do. Is it not possible to use the code with the functions of tables?

This works OK for me:

=SUMPRODUCT(SUBTOTAL(9,OFFSET(INDEX(Table1[Amount],1),ROW(Table1[Amount])-MIN(ROW(Table1[Amount])),0)),--(Table1[TypeID]=A5))

On a side note...

Do you actually like formulas using the structured referencing syntax? I absolutely loathe them! :mad:
 
Upvote 0
And it works for me too :biggrin:

Thank you very much. If the table is filtered it wont show the 'correct' amount. Is there a way to 'keep' the data even if it's hidden because of the filter?

Yes, I definitely like structured referencing syntax. I think it makes the syntax way more readable :biggrin:
 
Upvote 0
And it works for me too :biggrin:

Thank you very much. If the table is filtered it wont show the 'correct' amount. Is there a way to 'keep' the data even if it's hidden because of the filter?
In other words, you want the grand total whether the data is filtered or not? Actually, that's a whole lot easier!

=SUMIF(Table1[TypeID],A5,Table1[Amount])

Yes, I definitely like structured referencing syntax. I think it makes the syntax way more readable :biggrin:
Yeah, there's one in every crowd! :biggrin:
 
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,854
Members
449,051
Latest member
excelquestion515

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top