Sum if the first 4 digits of a column is the same as another column's first 4 digits

feni1388

Board Regular
Joined
Feb 19, 2018
Messages
127
Office Version
  1. 2021
Platform
  1. Windows
Hello....

Is there a formula that can sum if the first 4 digits a a column is the same as another column's 4 digits?
At the moment I'm using a helper column to take out the first 4 digits.
The total of L column that start with the same 4 digits as A column is shown in column C.

各病院の請求書(マクロ)0630 - feni test.xlsm
ABCDEFGHIJKL
1Customer codeTotal InvoiceIndividual InvoiceInvidual Invoice
2MC010000112,930112,930MC01MC01MC010101112,930
3MC020000253,620253,620MC02MC02MC020101187,110
4MC030000254,7400MC03MC02MC02020166,510
5MC04000000MC04 
6MC050000214,9050MC05 
7SIS01000892,0400SIS0 
8   
9   
10   
11   
確認用
Cell Formulas
RangeFormula
A2:A11A2=IF(FS請求一覧表!D2="","",FS請求一覧表!D2)
B2:B11B2=IF(FS請求一覧表!T2="","",FS請求一覧表!T2)
C2:C7C2=SUMIF(J:J,D:D,L:L)
D2:D7D2=LEFT(A2,4)
J2:J11J2=LEFT(K2,4)
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Try:
Book1
ABCDKL
1Customer codeTotal InvoiceIndividual Invoice
2MC010000112930MC010101112930
3MC020000253620MC020101187110
4MC0300000MC02020166510
5MC0400000
6MC0500000
7SIS010000
Sheet10
Cell Formulas
RangeFormula
C2:C7C2=SUM(FILTER($L$2:$L$4,LEFT($K$2:$K$4,4)=LEFT(A2,4),0))
 
Upvote 0
Solution
Try:
Book1
ABCDKL
1Customer codeTotal InvoiceIndividual Invoice
2MC010000112930MC010101112930
3MC020000253620MC020101187110
4MC0300000MC02020166510
5MC0400000
6MC0500000
7SIS010000
Sheet10
Cell Formulas
RangeFormula
C2:C7C2=SUM(FILTER($L$2:$L$4,LEFT($K$2:$K$4,4)=LEFT(A2,4),0))
Thank you. It works perfectly.
 
Upvote 0
The result is the same:

=SUMIF($K$2:$K$4,LEFT(A2,4)&"*",$L$2:$L$4)
 
Upvote 0

Forum statistics

Threads
1,221,776
Messages
6,161,870
Members
451,727
Latest member
tyedye4

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