Sum Across Worksheets with Two Criteria

dwgnome

Active Member
Joined
Dec 18, 2005
Messages
441
I am in need of a formula that can sum ranges across worksheets with more than one criteria.

The following works but looking for a way to simplify:

Code:
=SUMPRODUCT(--('Jan 2012'!$B$9:$B$55=K$8),--('Jan 2012'!$C$9:$C$55=D$16),'Jan 2012'!$H$9:$H$55)+SUMPRODUCT(--('Feb 2012'!$B$9:$B$55=K$8),--('Feb 2012'!$C$9:$C$55=D$16),'Feb 2012'!$H$9:$H$55)

I created a list of sheet names (Jan 2012, Feb 2012) and called it MnthTabs. I need to do this for all months of the year, so the formula above would get too unweildy.

I tried the following but it does not work.

=SUMPRODUCT(SUMIF(INDIRECT("'"&MnthTabs&"'!$B$9:$B$55"),K$8,INDIRECT("'"&MnthTabs&"'!$H$9:$H$55"))+SUMIF(INDIRECT("'"&MnthTabs&"'!$c$9:$c$55"),D$16,INDIRECT("'"&MnthTabs&"'!$H$9:$H$55")))

This results in a value, but the wrong value. It sums all values in H9:H55 for each condition found when K8="PI" and D16="Edgar Allen" independently. I need the sum only when both conditions exist in the ranges B9:B55 and C9:C55.

Thanks
 
Biff,

Most excellent! It apears to work as needed. I will run a more thorough test when I get back to my computer at home as I am traveling and just borrowed a friends ipad.

Could you explain why the need for the Offset function as all of the ranges are already defined and I thought arrays automatically start at the top of the array. Also what would the formula look like if I changed the list of worksheets (months) to vertical instead of horizontal.

Again thank you for stepping in with your expertise.
The OFFSET is "stepping thru" the sheet range one cell at a time.

In this application the sheet names must be in a horizontal array. If the sheet names are in a vertical array then you'd have to transpose them like this:

Now the formula must be array entered**.

=SUMPRODUCT(--(T(OFFSET(INDIRECT("'"&TRANSPOSE(MnthTabs)&"'!B9:B55"),ROW(INDIRECT("B9:B55"))-9,,))=K8),--(T(OFFSET(INDIRECT("'"&TRANSPOSE(MnthTabs)&"'!C9:C55"),ROW(INDIRECT("C9:C55"))-9,,))=D16),N(OFFSET(INDIRECT("'"&TRANSPOSE(MnthTabs)&"'!H9:H55"),ROW(INDIRECT("H9:H55"))-9,,)))

** array formulas need to be entered using the key
combination of CTRL,SHIFT,ENTER (not just ENTER).
Hold down both the CTRL key and the SHIFT key
then hit ENTER.
 
Upvote 0

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Forum statistics

Threads
1,221,310
Messages
6,159,173
Members
451,543
Latest member
cesymcox

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