Formula to total cells with same code in column next to them

sobrien1234

Board Regular
Joined
May 10, 2016
Messages
175
Office Version
  1. 365
Platform
  1. Windows
In column A I have a list of unique identifying numbers (codes) of which there may be many of the same code spread intermittently down the column. In column B I have a list of numbers that these codes represent. I want a formula that will add up all the numbers in column B that have the same unique identifier in column A. I tried =sum(if(a2:a1000=a2,b2:b1000)) but it doesn't work? I also highlighted it and press control/shift/enter and it turned into a #N/A

Any suggestions?

Thanks
 
Last edited:

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Code:
=sumif(a:a,a2,b:b)

Note: Your formula would work if you pressed CTRL+SHIFT +Enter after you typed it to get brackets around it (Array formula) but I would recommand sumif function instead
 
Last edited:
Upvote 0
Maybe try;


Book1
ABCD
1unique1100UINResult
2101unique1995
3102
4103
5unique1104
6105
7unique1106
8107
9unique1108
10109
11110
12unique1111
13112
14113
15114
16unique1115
17unique1116
18unique1117
19unique1118
Sheet1
Cell Formulas
RangeFormula
D2=SUMPRODUCT(($A$1:$A$19=$C$2)*$B$1:$B$19)
 
Upvote 0
Maybe try;

ABCD
1unique1100UINResult
2101unique1995
3102
4103
5unique1104
6105
7unique1106
8107
9unique1108
10109
11110
12unique1111
13112
14113
15114
16unique1115
17unique1116
18unique1117
19unique1118

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

Worksheet Formulas
CellFormula
D2=SUMPRODUCT(($A$1:$A$19=$C$2)*$B$1:$B$19)

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

<tbody>
</tbody>

Thanks
 
Upvote 0

Forum statistics

Threads
1,215,046
Messages
6,122,855
Members
449,096
Latest member
Erald

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