# SUMIF simplification - multiple criteria

#### gaj104

##### Well-known Member
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

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Try...

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

Hope this helps!

=-sum(sumif(PL2006!AO:AO,{"Ech","XCH"},PL2006!AN:AN))

You can add variables within the curly brackets

EDIT: Beaten!!

Excellent stuff guys. Many thanks

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..

I added the Sum around the formula and it works. Can someone explain why it needs to be wrapped in a sum () please ?

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!

Great explanation. Appreciated

Replies
3
Views
127
Replies
17
Views
638
Replies
3
Views
218
Replies
3
Views
326
Replies
18
Views
823

1,217,481
Messages
6,136,903
Members
450,029
Latest member
MissQuotation

### 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.

### Which adblocker are you using?

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

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