# Sum specific cells in column based on multiple row criteria

#### generalmonk

##### New Member
I cannot find an answer to this anywhere, so hoping you can help! I have a list of ref IDs in Column A which may or may not be unique (eg. 1, 1, 1, 2, 3, 3, 4, 4 ,4 ,4...etc). I need to be able to find the last instance of EACH of these ref IDs in Column A and sum the associated cell values in a column further along in the Spreadsheet. Many thanks in advance.

#### generalmonk

##### New Member

Sorry Sandy666, thanks kindly for the table, but I am just looking for a formula... would it help if I said the last row of each ID instance was associated with the smallest number in the other column? ie. sum the smallest numbers for each ID (which translate to the last instance of each ID).

Also, Maabadi's lookup formula works but only for one ID instance (eg. ID 1), so I need to add the Lookups (Lookup with ID 1 + Lookup with ID 2, etc. until an arbitary number like 100 or so, which hopefully assumes the IDs do not go beyond 100!) However, is there a way to tell Excel to add nth lookups like this incrementing by 1 every time (representing the next ID) based on the max ID value? Hope that makes sense.

Thanks again and sorry for being a pain...

### Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

#### generalmonk

##### New Member
Thanks all, I have now resolved it with the following equation:

Excel Formula:
``=SUM(XLOOKUP(UNIQUE(A5:A...),A5:A...,P5:P...,"",0,-1))``

Last edited by a moderator:

Replies
3
Views
152
Replies
1
Views
108
Replies
2
Views
380
Replies
1
Views
29
Replies
10
Views
154

1,127,243
Messages
5,623,579
Members
415,981
Latest member
Baltwin

### 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.

### Which adblocker are you using?

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

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