sumif for all numbers starting with a couple digits

bigdan

Well-known Member
Joined
Oct 5, 2009
Messages
846
Office Version
  1. 2013
Platform
  1. Windows
I want to get the sum of all numbers in col b when the ID in col a starts with 14.

So for example

[TABLE="width: 500"]
<tbody>[TR]
[TD]14012[/TD]
[TD]50[/TD]
[/TR]
[TR]
[TD]15000[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]14999[/TD]
[TD]100[/TD]
[/TR]
[TR]
[TD]16045[/TD]
[TD]3[/TD]
[/TR]
</tbody>[/TABLE]


=SUMIF(a:a,"14*",b:b)

I'm getting a zero.

My formula seems to work for text in col A but not for numbers.

Help please!
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
could try something like the below:

Code:
=SUMPRODUCT($B$1:$B$4,--(--LEFT($A$1:$A$4,2)=14))
 
Upvote 0
Try:

=SUMPRODUCT((LEFT(A1:A4,2)="14")*(B1:B4))

Or:


Book1
ABC
11401250
2150001150
314999100
4160453
Hoja1
Cell Formulas
RangeFormula
C2{=SUM(IF(LEFT(A1:A4,2)="14",B1:B4))}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Thanks guys. Would a SUMIF not work? That would be so much simpler than a sumproduct
 
Upvote 0
Sumif can not check a text string.
If you do not want sumproduct, there is the option of SUM(IF



Array Formulas

<thead>
[TH="width: 10px, align: center"]Cell[/TH]
[TH="align: left"]Formula[/TH]

</thead><tbody>
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] , align: center"]C2[/TH]
[TD="align: left"]{=SUM( IF(LEFT(A1:A4,2)="14",B1:B4) )}

<tbody>

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

[/TD]

</tbody>

****** id="cke_pastebin" style="position: absolute; top: 23.4517px; width: 1px; height: 1px; overflow: hidden; left: -1000px;">
Array Formulas

<thead>
[TH="width: 10px, align: center"]Cell[/TH]
[TH="align: left"]Formula[/TH]

</thead><tbody>
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] , align: center"]C2[/TH]
[TD="align: left"]{=SUM( IF(LEFT(A1:A4,2)="14",B1:B4) )}

<tbody>

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

[/TD]

</tbody>
</body>
 
Upvote 0
Assuming the IDs are all 5-digit numbers,

[Table="width:, class:grid"][tr][td="bgcolor:#C0C0C0"][/td][td="bgcolor:#C0C0C0"]
A​
[/td][td="bgcolor:#C0C0C0"]
B​
[/td][td="bgcolor:#C0C0C0"]
C​
[/td][td="bgcolor:#C0C0C0"]
D​
[/td][/tr][tr][td="bgcolor:#C0C0C0"]
2​
[/td][td]
14012​
[/td][td]
50​
[/td][td="bgcolor:#CCFFCC"]
150​
[/td][td="bgcolor:#CCFFCC"]C2: =SUMIFS(B2:B5, A2:A5, ">=14000", A2:A5, "<15000")[/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
3​
[/td][td]
15000​
[/td][td]
1​
[/td][td][/td][td][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
4​
[/td][td]
14999​
[/td][td]
100​
[/td][td][/td][td][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
5​
[/td][td]
16045​
[/td][td]
3​
[/td][td][/td][td][/td][/tr]
[/table]
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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