Using sumproduct with only visible cells?

Pezz3r

New Member
Joined
Apr 15, 2011
Messages
6
Hi,

I have a sumproduct formula something like this:
=SUMPRODUCT(O9:O37,$M9:$M37)/SUM($M9:$M37)

However I am using a filter and I want the value to change depending on which rows are selected.

For simple SUMs I've used SUBTOTAL, is there an equivalent for SUMPRODUCT?
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Welcome to the board!

Try using a helper column with subtotal.

In N9 (or next avaliable column) enter =SUBTOTAL(109,M9) and fill that down no N37

Then in your sumproduct formula add the criteria to compare the subtotal to the actual, for example

=SUMPRODUCT(O9:O37,--(M9:M37=N9:N37),$M9:$M37)
 
Upvote 0
You could avoid a helper column by using this formula

=SUMPRODUCT(O9:O37,SUBTOTAL(9,OFFSET($M9,ROW($M9:$M37)-ROW($M9),0)))/SUBTOTAL(9,$M9:$M37)
 
Upvote 0
Thanks Barry that's perfect.

Was trying to avoid helper columns etc. if only to show off when this report gets circul8d :cool:
 
Upvote 0
Thanks Barry that's perfect.

Was trying to avoid helper columns etc. if only to show off when this report gets circul8d :cool:

Does the result change with the filter?

I would have thought that you would need

=SUMPRODUCT(O9:O37,SUBTOTAL(109,OFFSET($M9,ROW($M9:$M37)-ROW($M9),0)))/SUBTOTAL(109,$M9:$M37)

To ignore the hidden rows.
 
Upvote 0
Looks like either work.

If I'm honest with you Jason, and I may as well be, I've no idea why. In the excel help it says use 109 to hide visible cells.
 
Upvote 0
It could be a difference in data setup, I tried barry's formula to see how it worked and found the result was unchanged regardless of the filter, it also returned a value when there were no rows visible, which, in theory should result in a #DIV/0! error.
 
Upvote 0
Are you definitely using a filter or manually hiding the rows though?

I was doing manual to start, and forgot to change the formula back to barry's version before trying it on filter. Sorry if I caused any confusion.
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,733
Members
452,939
Latest member
WCrawford

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