Sum based on range of multiple criteria....

AnaChela

New Member
Joined
Jan 18, 2013
Messages
2
There's got to be a better way!

In the example below, I want to sum column C only if none of values in column D appear in column B:

BC D
2aaa1bbb
3bbb1eee
4ccc1hhh
5aaa1qqq
6abc1
7ccc1
8qqq1
9bbb1
10bbb1
11hhh1
12hhj1
13eee1
14eee1

<colgroup><col><col span="3"></colgroup><tbody>
</tbody>

I can do it with an array:
{=SUM((C2:C14)*(B2:B14<>D2)*(B2:B14<>D3)*(B2:B14<>D4)*(B2:B14<>D5))}

But in my real spreadsheet, column D will have 25 or more values. This feels like a very messy way to get what I'm looking for. Does anyone have an easier, cleaner way to do this?
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
How about this?

=SUM(--ISNUMBER(MATCH($B$2:$B$14,$D$2:$D$5,0))*($C$2:$C$14))
 
Upvote 0
I just saw that you want to sum the numbers that don't have matches. That would be

=SUM(--NOT(ISNUMBER(MATCH(B2:B14,D2:D5,0))*(C2:C14)))

Both of these are also array formulas.
 
Upvote 0
Slight alteration.

=SUM(--ISNA(MATCH(B2:B14,D2:D5,0))*(C2:C14))
 
Upvote 0
Slight alteration.

=SUM(--ISNA(MATCH(B2:B14,D2:D5,0))*(C2:C14))


It worked!! Here's the actual formula I used: {=ABS(SUM(--ISNA(MATCH(G7:G42,Categories!B1:B27,0))*(J7:J42)))}

I knew there was a better way, thanks for introducing me to ISNA!
 
Upvote 0
{=ABS(SUM(--ISNA(MATCH(G7:G42,Categories!B1:B27,0))*(J7:J42)))}

In fact the -- aren't required here, this should work

=ABS(SUM(ISNA(MATCH(G7:G42,Categories!B1:B27,0))*(J7:J42)))

confirmed with CTRL+SHIFT+ENTER

or you can use SUMPRODUCT to avoid array entry, e.g.

=ABS(SUMPRODUCT(ISNA(MATCH(G7:G42,Categories!B1:B27,0))+0,J7:J42))
 
Upvote 0

Forum statistics

Threads
1,214,861
Messages
6,121,973
Members
449,059
Latest member
oculus

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