sumif for all numbers starting with a couple digits

bigdan

Well-known Member
Joined
Oct 5, 2009
Messages
843
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

1401250
150001
14999100
160453

<tbody>
</tbody>


=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

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
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
CellFormula
C2{=SUM(IF(LEFT(A1:A4,2)="14",B1:B4))}

<thead>
</thead><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


<tbody>
</tbody>

****** id="cke_pastebin" style="position: absolute; top: 23.4517px; width: 1px; height: 1px; overflow: hidden; left: -1000px;">
Array Formulas
CellFormula
C2{=SUM(IF(LEFT(A1:A4,2)="14",B1:B4))}

<thead>
</thead><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


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

A​
B​
C​
D​
2​
14012​
50​
150​
C2: =SUMIFS(B2:B5, A2:A5, ">=14000", A2:A5, "<15000")
3​
15000​
1​
4​
14999​
100​
5​
16045​
3​
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,528
Messages
6,125,338
Members
449,218
Latest member
Excel Master

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