Formulae to sum totals from duplicate references

fauxlidae

New Member
Joined
Sep 21, 2023
Messages
8
Office Version
  1. 365
Platform
  1. Windows
I'm trying to build some code that will scan a set of data in column F for a duplicate text reference and, once a duplicate is identified, will sum the associated number in column M of the same row. Each duplicate reference should be summed separately, i.e, a payment of £15 and a payment of £10, both with the duplicate reference 'Josh', need to be added together, and a payment of £7 and £9 for duplicate reference 'Sarah' need to be summed together in a separate total.

Column M also contains some N/A references, and the code needs to exclude these from any attempt to sum - i.e, if 'Josh' also has a row with N/A, then this musn't stop Excel from summing the £15 and £10.

Once these amounts are conjugated into a single row (i.e, a row where Josh has a total of £25), the individual rows that were added together need to be deleted.

1695301485831.png


I have some VBA knowledge, but it's quite basic and i'm not sure how to build up a multi-stage process like this.

Any help much appreciated!
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Simplest solution would be to change the N/A to 0 and use sumif
 
Upvote 0
Simplest solution would be to change the N/A to 0 and use sumif
Unfortunately the N/A is an #N/A error generated by Excel - sorry, should have specified that! The result of a VLOOKUP not finding any data
 
Upvote 0
Group By in Power Query

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Filtered Rows" = Table.SelectRows(Source, each ([Spend] <> "N/A")),
    #"Grouped Rows" = Table.Group(#"Filtered Rows", {"Customer reference"}, {{"Total", each List.Sum([Spend]), type number}})
in
    #"Grouped Rows"

Book11
ABCDE
2Customer referenceSpendCustomer referenceTotal
3Josh10Josh20
4Sarah7Sarah16
5Ryan12Ryan12
6JoshN/A
7Sarah9
8Josh10
Sheet1
 
Upvote 0
a different way to try it:

Mr excel questions 63.xlsm
ABCDEFG
1
2Customer ReferenceSpend
3Josh10Josh20
4Sarah7Sarah22
5Ryan12Ryan9
6Josh#N/A
7Sarah9
8Josh10
9
fauxlidae
Cell Formulas
RangeFormula
E3:E5E3=UNIQUE(B3:B8)
F3:F5F3=SUM(($B$3:$B$8=E3)*IF(ISNA(C3:C8),0,C3:C8))
C6C6=NA()
Dynamic array formulas.


This won't auto delete the rows when you get to 25. But you can use the rules for conditional formatting to highlight the rows.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,959
Members
449,096
Latest member
Anshu121

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