Consolidating duplicate identifiers

Ports_008

New Member
Joined
Apr 6, 2023
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hello all,

I'm struggling with a scenario at present. I'm trying to reconcile our weekly carrier invoices into a flat spreadsheet to be imported into our system. I have compiled a macro in VBA to take our carriers CSV and format into a structure acceptable, the last thing I have to do now is identify when a consignment note is listed more than once, and consolidate their respective values to a single line.

An example is below of what my data currently looks like. Can anyone help with a solution in VBA that will identify the secondary charges for connote 1 and 3, update the value in the first row instance (A2, A4 below) to the sum of each line (there may be more than 2 records), and remove the 2nd or 3rd instance from the workbook? All detail represented by 'xxx' would remain consistent with what is present in the first row the consignment note is found (discard changes such as 'XXz' found in the secondary charges.


From This

AMOUNTINVOICEDATEINVOICEIDSHIPMENTIDTAXITEMGROUPVENDACCOUNTVENDCONSIGNMENTNUMVENDORSHIPDATEWORKER
19.23​
xxxxxxxxxxxxxxxCONNOTE001xxxxxx
23.01​
xxxxxxxxxxxxxxxCONNOTE002xxxxxx
27.84​
xxxxxxxxxxxxxxxCONNOTE003xxxxxx
26.86​
xxxxxxxxxxxxxxxCONNOTE004xxxxxx
12.65​
xxxxxxxxxxxxxxxMANUAL HANDLING ROAD CONNOTE001xxxxxx
12.65​
xxxxxxXXzxxxxxx2ND DELIV CHARGE CONNOTE001xxxxxx
12.65​
xxxxxxXXzxxxxxx2ND DELIV CHARGE CONNOTE003xxxxxx


To This

AMOUNTINVOICEDATEINVOICEIDSHIPMENTIDTAXITEMGROUPVENDACCOUNTVENDCONSIGNMENTNUMVENDORSHIPDATEWORKER
44.53​
xxxxxxxxxxxxxxxCONNOTE001xxxxxx
23.01​
xxxxxxxxxxxxxxxCONNOTE002xxxxxx
40.49​
xxxxxxxxxxxxxxxCONNOTE003xxxxxx
26.86​
xxxxxxxxxxxxxxxCONNOTE004xxxxxx


I hope this makes sense, and thanks in advance.
 

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.
You will need a seperate column to calculate the Consignment Note total.

Put this formula in that column where column G is the VENDCONSIGNMENTNUM column and A is the AMOUNT column.

You will need change the scopes of the column A and G ranges.

=IF(IFERROR(FIND(" ",$G2,1),0)=0,SUMIF($G$2:$G$8,"*" & $G2,$A$2:$A$8),"")
 
Upvote 0
You can try :

Book13
ABCDEFGHI
1AMOUNTINVOICEDATEINVOICEIDSHIPMENTIDTAXITEMGROUPVENDACCOUNTVENDCONSIGNMENTNUMVENDORSHIPDATEWORKER
219.23xxxxxxxxxxxxxxxCONNOTE001xxxxxx
323.01xxxxxxxxxxxxxxxCONNOTE002xxxxxx
427.84xxxxxxxxxxxxxxxCONNOTE003xxxxxx
526.86xxxxxxxxxxxxxxxCONNOTE004xxxxxx
612.65xxxxxxxxxxxxxxxMANUAL HANDLING ROAD CONNOTE001xxxxxx
712.65xxxxxxXXzxxxxxx2ND DELIV CHARGE CONNOTE001xxxxxx
812.65xxxxxxXXzxxxxxx2ND DELIV CHARGE CONNOTE003xxxxxx
9
10
11AMOUNTINVOICEDATEINVOICEIDSHIPMENTIDTAXITEMGROUPVENDACCOUNTVENDCONSIGNMENTNUMVENDORSHIPDATEWORKER
1244.53xxxxxxxxxxxxxxxCONNOTE001xxxxxx
1323.01xxxxxxxxxxxxxxxCONNOTE002xxxxxx
1440.49xxxxxxxxxxxxxxxCONNOTE003xxxxxx
1526.86xxxxxxxxxxxxxxxCONNOTE004xxxxxx
Data
Cell Formulas
RangeFormula
B12:I15B12=FILTER(B2:I8,LEN(G2:G8)=10)
A11:I11A11=A1:I1
A12:A15A12=IFERROR(SUMIF($G$2:$G$8,"*" & $G12,$A$2:$A$8),0)
Dynamic array formulas.
 
Upvote 0
You will need a seperate column to calculate the Consignment Note total.

Put this formula in that column where column G is the VENDCONSIGNMENTNUM column and A is the AMOUNT column.

You will need change the scopes of the column A and G ranges.

=IF(IFERROR(FIND(" ",$G2,1),0)=0,SUMIF($G$2:$G$8,"*" & $G2,$A$2:$A$8),"")
Thanks for providing this. This works perfectly to pick up the secondary consignment charges. I do need to do more work as it is looking for a space and I know there are other charges that may have a space that are valid.
 
Upvote 0
Can you give a representative list of what would be in the VENDCONSIGNMENTNUM colomn that may also be valid?
 
Upvote 0
Can you give a representative list of what would be in the VENDCONSIGNMENTNUM colomn that may also be valid?

LATE PAYMENT CHARGE _23039
ACCOUNT ADMIN FEE

I may not be able to proceed with this though. I've just been informed it's possible a secondary charge may not always be processed in the same billing cycle as the original charge which will make things problematic.
 
Upvote 0
If the data indicates in some way that it will not be charged then I am sure that it is possible to do.
 
Upvote 0

Forum statistics

Threads
1,224,548
Messages
6,179,448
Members
452,915
Latest member
hannnahheileen

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