Sumifs with contains

adrienne0914

Board Regular
Joined
Mar 22, 2018
Messages
57
Office Version
  1. 2016
Platform
  1. Windows
Looking for help with SUMIFS. I need the sum if Column A contains "53", "Vat" or both.

ChargeAmount
C5305-R-D - Duty83,942
C5315-R-D - Gst Paid411,816
5315-R-D - Cisf2,985
5315-E-D - Gst Paid233,045
153-R-D - Cisf2,985
153-R-O - Cisf32,410
VAT-E-D - Customs Vat62,762
5319-E-D - Vat1,436

<tbody>
</tbody>

Thanks for any help!
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Hi,

If I understand correctly, this is one way:


Book1
ABCD
1ChargeAmount
2C5305-R-D - Duty83,942831,381
3C5315-R-D - Gst Paid411,816
45315-R-D - Cisf2,985
55315-E-D - Gst Paid233,045
6153-R-D - Cisf2,985
7153-R-O - Cisf32,410
8VAT-E-D - Customs Vat62,762
95319-E-D - Vat1,436
Sheet146
Cell Formulas
RangeFormula
D2=SUM(SUMIFS(B2:B9,A2:A9,{"*53*","*Vat*"}))-SUMIFS(B2:B9,A2:A9,"*53*",A2:A9,"*Vat*")


The reason I'm unsure this is what you want, you didn't provide an Expected result, and for your sample, it happens that the entire Column A matches the criterion you mentioned.
 
Upvote 0
Using SUMIFS is fine here. But you can also try this array formula:


Book1
AB
1ChargeAmount
2C5305-R-D - Duty83,942
3C5315-R-D - Gst Paid411,816
45315-R-D - Cisf2,985
55315-E-D - Gst Paid233,045
6153-R-D - Cisf2,985
7153-R-O - Cisf32,410
8VAT-E-D - Customs Vat62,762
95319-E-D - Vat1,436
10831,381
Sheet17
Cell Formulas
RangeFormula
B10{=SUM(IF(ISNUMBER(SEARCH(53,A2:A9))+ISNUMBER(SEARCH("vat",A2:A9)),B2:B9))}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Last edited:
Upvote 0
Hi,

If I understand correctly, this is one way:

ABCD
1ChargeAmount
2C5305-R-D - Duty83,942831,381
3C5315-R-D - Gst Paid411,816
45315-R-D - Cisf2,985
55315-E-D - Gst Paid233,045
6153-R-D - Cisf2,985
7153-R-O - Cisf32,410
8VAT-E-D - Customs Vat62,762
95319-E-D - Vat1,436

<colgroup><col style="width: 25pxpx"><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet146

Worksheet Formulas
CellFormula
D2=SUM(SUMIFS(B2:B9,A2:A9,{"*53*","*Vat*"}))-SUMIFS(B2:B9,A2:A9,"*53*",A2:A9,"*Vat*")

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>

The reason I'm unsure this is what you want, you didn't provide an Expected result, and for your sample, it happens that the entire Column A matches the criterion you mentioned.


My bad! I just realized that they all fall into that criteria. There are thousands of cells in the actual file with just a few matching the criteria. I just wasn't sure how to use OR with SUMIFS. I tried this formula out. I think the final result is higher than it should be, but I can definitely work with it. Thanks!
 
Upvote 0
Using SUMIFS is fine here. But you can also try this array formula:

AB
1ChargeAmount
2C5305-R-D - Duty83,942
3C5315-R-D - Gst Paid411,816
45315-R-D - Cisf2,985
55315-E-D - Gst Paid233,045
6153-R-D - Cisf2,985
7153-R-O - Cisf32,410
8VAT-E-D - Customs Vat62,762
95319-E-D - Vat1,436
10831,381

<colgroup><col style="width: 25pxpx"><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet17

Array Formulas
CellFormula
B10{=SUM(IF(ISNUMBER(SEARCH(53,A2:A9))+ISNUMBER(SEARCH("vat",A2:A9)),B2:B9))}

<thead>
</thead><tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try to enter the {} manually yourself

<tbody>
</tbody>

I got a #N/A error with this formula. I did enter with Ctrl+Shift+Enter. :) I don't need to put 53 in quotation marks or make it or "vat" a wildcard?
 
Upvote 0
No problem at all.

If my formula isn't giving you correct results, please provide a sample (with the expected result) where my formula fails, may be we can get it sorted out.
 
Upvote 0
No problem at all.

If my formula isn't giving you correct results, please provide a sample (with the expected result) where my formula fails, may be we can get it sorted out.

In looking at it again, I think your formula is right. But what if I wanted to add another condition... say "gst"... So sum if Column A contains "53", "Vat", "gst" or a combination of these.

ChargeAmount
C01-R-D - Import Gst

<tbody>
</tbody>
23,889
3836-E-O - On & Off

<tbody>
</tbody>
2,186
5315-E-D - Gst Paid

<tbody>
</tbody>
233,045
5315-R-D - Cisf

<tbody>
</tbody>
2,985
6319-E-D - Var

<tbody>
</tbody>
1,436
C5305-R-D - Duty

<tbody>
</tbody>
83,942
COMV-E-D - Frt Commission Subj To Vat

<tbody>
</tbody>
2,200
CRT-R-O - Crating

<tbody>
</tbody>
5,153
VAT-R-D - Customs Vat

<tbody>
</tbody>
61,235
WO-R-O - Whse Other

<tbody>
</tbody>
4,495
TOTAL420,566

<tbody>
</tbody>

Expected result is
407,296

Thanks again for your help!
 
Upvote 0

Book1
ABCD
1ChargeAmount53
2C01-R-D - Import Gst23,889vat
33836-E-O - On & Off2,186gst
45315-E-D - Gst Paid233,045
55315-R-D - Cisf2,985407,296
66319-E-D - Var1,436
7C5305-R-D - Duty83,942
8COMV-E-D - Frt Commission Subj To Vat2,200
9CRT-R-O - Crating5,153
10VAT-R-D - Customs Vat61,235
11WO-R-O - Whse Other4,495
12TOTAL420,566
Sheet1


In D5 control+shift+enter, not just enter:

=SUM(IF(MMULT(ISNUMBER(SEARCH(TRANSPOSE(D1:D3),$A$2:$A$11))+0,ROW(D1:D3)^0),$B$2:$B$11))
 
Upvote 0
ABCD
1ChargeAmount53
2C01-R-D - Import Gst23,889vat
33836-E-O - On & Off2,186gst
45315-E-D - Gst Paid233,045
55315-R-D - Cisf2,985407,296
66319-E-D - Var1,436
7C5305-R-D - Duty83,942
8COMV-E-D - Frt Commission Subj To Vat2,200
9CRT-R-O - Crating5,153
10VAT-R-D - Customs Vat61,235
11WO-R-O - Whse Other4,495
12TOTAL420,566

<colgroup><col style="width: 25pxpx"><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet1

In D5 control+shift+enter, not just enter:

=SUM(IF(MMULT(ISNUMBER(SEARCH(TRANSPOSE(D1:D3),$A$2:$A$11))+0,ROW(D1:D3)^0),$B$2:$B$11))

Awesome! This is perfect because the specs on what to sum keep changing. Thanks so much!! :biggrin:
 
Upvote 0

Forum statistics

Threads
1,214,522
Messages
6,120,022
Members
448,939
Latest member
Leon Leenders

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