sumif multiple criteria

basher450

New Member
Joined
Jan 26, 2005
Messages
23
little help with something I thought would be simple:
in A column I have names:
A1 = "josh"
A2 = "dani"
A3 = "bobby"

in B column I have numbers:
B1 = 2
B2 = 4
B3 = 5

I want to sum the B values for "josh" and "dani" only. (B1 and B2)

I tried this:
=SUMIF(A1:A3, "josh, dani", B1:B3)
and this:
=SUMIF(A1:A3, OR(josh, dani), B1:B3)

always returns 0
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
How about:

Excel Workbook
ABCDEF
1josh2josh6
2dani4dani
3bobby5
Sheet1
Excel 2003
Cell Formulas
RangeFormula
F1=SUMPRODUCT(SUMIF(A1:A3,D1:D2,B1:B3))

D1:D2 contains the values you want to sum from the dataset A1:B3.

Does this help?

Matty
 
Upvote 0
Sum if will not take multiple criteria
If you have 2007 sumifs will.

meanwhile try

=SUMIF(A1:A3, "josh", B1:B3)+=SUMIF(A1:A3, "dani", B1:B3)
 
Upvote 0
If you want a single SUMIF as you attempted then the syntax would be like this....

=SUM(SUMIF(A1:A3, {"josh", "dani"}, B1:B3))

Edit: of course that's similar to Matty's suggestion. If you use the "array constant" {"josh", "dani"} then you can use SUM but if you replace that with a range then you can use SUMPRODUCT to avoid CSE.......
 
Last edited:
Upvote 0
Hello barry houdini,

Is CSE actually required with your array constant suggestion? It seems to work without...

Matty
 
Upvote 0
Hello barry houdini,

Is CSE actually required with your array constant suggestion? It seems to work without...

Matty

{"josh", "dani"} as criteria, which is an array constant, you need an ordinary SUM to total the SumIf results, no CSE.

If you use a range like D1:D2 housing the criteria, you need array processing:

Either...

=SUMPRODUCT(SUMIF(A1:A3,D1:D2,B1:B3))

which needs just enter;

Or...

=SUM(SUMIF(A1:A3,D1:D2,B1:B3))

which would require CSE...
 
Upvote 0
How about:

Excel Workbook
ABCDEF
1josh2josh6
2dani4dani
3bobby5
Sheet1
Excel 2003
Cell Formulas
RangeFormula
F1=SUMPRODUCT(SUMIF(A1:A3,D1:D2,B1:B3))

D1:D2 contains the values you want to sum from the dataset A1:B3.

Does this help?

Matty

this worked
thankd
 
Upvote 0
Thanks to Aladin and Colin for their explanations.

The link Colin posted is a real eye-opener. Shall bear the results in mind when doing conditional summing in future!

Cheers,

Matty
 
Upvote 0

Forum statistics

Threads
1,223,248
Messages
6,171,011
Members
452,374
Latest member
keccles

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