SUMIF simplification - multiple criteria

gaj104

Well-known Member
Joined
Nov 9, 2002
Messages
864
Hi,

I'm using a cumbersome SUMIF formula

=-SUMIF(PL2006!AO:AO,"ECH",PL2006!AN:AN)-SUMIF(PL2006!AO:AO,"XCH",PL2006!AN:AN)

I tried to change it to the following but it did not work

=-SUMIF(PL2006!AO:AO,OR("ECH","XCH"),PL2006!AN:AN)

Is there a formula to simplfy the first one, mainly as I will need to add futher 3 letter criteria.

Many thanks
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Domenic

MrExcel MVP
Joined
Mar 10, 2004
Messages
19,700
Try...

=-SUM(SUMIF(PL2006!AO:AO,{"ECH","XCH"},PL2006!AN:AN))

Hope this helps!
 

JohnnyTightlips

Board Regular
Joined
Aug 13, 2006
Messages
94
=-sum(sumif(PL2006!AO:AO,{"Ech","XCH"},PL2006!AN:AN))

You can add variables within the curly brackets

EDIT: Beaten!!
 

BruceyBonu$

Board Regular
Joined
Mar 6, 2006
Messages
74

ADVERTISEMENT

that looks really useful.. but I cant get that to work, any ideas what Im doing wrong...
my formula to test was..
=SUMIF(H:H,{"s","sd"},G:G)
it only counts those that equal "s" though..
 

BruceyBonu$

Board Regular
Joined
Mar 6, 2006
Messages
74
I added the Sum around the formula and it works. Can someone explain why it needs to be wrapped in a sum () please ?
 

Domenic

MrExcel MVP
Joined
Mar 10, 2004
Messages
19,700
I added the Sum around the formula and it works. Can someone explain why it needs to be wrapped in a sum () please ?

In this case, SUMIF has two values as its criteria, as specified by the array constant...

{"s","sd"}

Since the criteria is an array, SUMIF returns an array made up of two values. The first value with "s" as its criteria, and the second with "sd". These values are then passed to SUM which it sums.

Hope this helps!
 

Forum statistics

Threads
1,136,878
Messages
5,678,320
Members
419,755
Latest member
eshnider21

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
Top