Sumif Using Wildcard

cunningAce

Board Regular
Joined
Dec 21, 2017
Messages
91
Office Version
  1. 365
Platform
  1. Windows
Hi,

I'm am trying to perform a sum if on the below data.
I want to sum only the numbers that begin with the year 2018 (or what ever selection I chose) so I tried the following but it returns zero?

=SUMIF(A1:A8,"2018*",B1:B8)

Also tried with 2018 typed in cell G1

=SUMIF(A1:A8,G1&"*",B1:B8)


Column A Colum B
201801 50
201802 60
201803 70
201804 80
201805 90
201901 50
201902 60
201903 70

Any help greatly appreciated.
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Try this:
Code:
=SUMPRODUCT(--(LEFT(A1:A8,4)="2018"),B1:B8)
 
Upvote 0
Excel 2010
ABCDE
1201801502018350
220180260
320180370
420180480
520180590
620190150
720190260
820190370

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

Worksheet Formulas
CellFormula
E1=SUMPRODUCT((LEFT(A1:A8,4)=$D$1)*B1:B8)

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

<tbody>
</tbody>
 
Upvote 0
=SUMPRODUCT(
(LEFT(A1:A8,4)=$D$1)*B1:B8
)
returns 0

needed to turn the string back to number by *1 to get it to work.

Thanks
 
Upvote 0
Assuming column A is year and month, you could also use SUMIFS

=SUMIFS(B2:B9,A2:A9,">201800",A2:A9,"<201813")
or
=SUMIFS(B2:B9,A2:A9,">"&G1*100,A2:A9,"<"&G1&13)
 
Upvote 0
Your cell $D$1 must contain the text value of 2018, by using the apostrophe ' before the 2018, like '2018, since the Left() function converts its object into text.
Does that help?
 
Upvote 0
Try this:
Code:
=SUMPRODUCT(--(LEFT(A1:A8,4)="2018"),B1:B8)

So I have gone with this formula, thanks all.

How would I add a further condition?
So it would only sum values that start with 2018 (as does currently) but then also sums only values that have "Q1" in column C

Much appreciated :)
 
Upvote 0
How would I add a further condition?
So it would only sum values that start with 2018 (as does currently) but then also sums only values that have "Q1" in column C
For my suggestion, the alteration would be

=SUMIFS(B2:B9,A2:A9,">201800",A2:A9,"<201813",C2:C9,"Q1")

Edit: Looking back to post #1 , my row ranges should be 1:8 not 2:9. Same in my previous post.
 
Last edited:
Upvote 0
Just keep adding conditions, i.e.
Code:
=SUMPRODUCT(--(LEFT(A1:A8,4)="2018"),[COLOR=#ff0000]--(C1:C8="Q1")[/COLOR],B1:B8)
 
Upvote 0

Forum statistics

Threads
1,214,895
Messages
6,122,128
Members
449,066
Latest member
Andyg666

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