Array formulas - using Subtotal function?

JROM

Board Regular
Joined
Nov 28, 2005
Messages
53
Is it possible to use the subtotal function within an array formula? I've used array formulas for sum, count, average; and they work fine, but when I tried using subtotal, I get an error message.

Does anyone know if this works or not?
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Try...

=SUMPRODUCT(--(CondRange="Cond"),SUBTOTAL(9,OFFSET(RangeToSum,ROW(RangeToSum)-MIN(ROW(RangeToSum)),0,1)))

Note that if the condition is a numerical value, remove the quotes.

Hope this helps!
 
Upvote 0
Thank you so much for your help. That worked beautifully, and gives the exact results that I'm looking for!

Only one question, though. How does that formula actually work? I've tried to step through the formula, and have tried to look up each of the functions in the help, but still can't really understand why it works.

Would it be possible to explain it in layman terms to me?
 
Upvote 0
Thanks again! That link explained how the "offset" portion of the formula worked. It hurt my brain, but I'm pretty sure I understood it.

Now, for the first part of the formula:

=SUMPRODUCT(--(CondRange="Cond"),

What does the -- mean? It almost looks like either an IF formula, or a WHERE formula, but I've never seen that used before.
 
Upvote 0
The conditional statement...

CondRange="Cond"

...returns an array of TRUE and FALSE. The double negative '--' coerces these values into their numerical equivalent, 1 and 0 respectively. Have a look here..
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,260
Members
452,627
Latest member
KitkatToby

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