Match three columns together across sheet to subtraction based invoice number

abdo meghari

Well-known Member
Joined
Aug 3, 2021
Messages
532
Office Version
  1. 2019
Hello
I have theses data for four sheets
DECREASE.xlsm
ABCDEFGHI
1ITEMDATEINV.NOBRANDTYPEORIGINQTY PRICETOTAL
2115/06/2023BSTR_23448BS 750R16R230JAP4.00500.002,000.00
3215/06/2023BSTR_23448BS 700R16R230JAP2.00400.00800.00
4SUM2,800.00
5115/09/2023BSTR_23449GO 1200R20AZ0026CHI1.00920.00920.00
6215/09/2023BSTR_23449GO 1200R20AZ0083CHI2.001,000.002,000.00
7SUM2,920.00
8115/09/2023BSTR_23450BS 1200R20G580JAP10.001,800.0018,000.00
9215/09/2023BSTR_23450BS 1200R20G580THI10.001,800.0018,000.00
10315/09/2023BSTR_23450BS 1200R20R187THI10.001,800.0018,000.00
11SUM54,000.00
12116/09/2023BSTR_23451BS 215/60R16ER30JAP4.00400.001,600.00
13SUM1,600.00
14116/09/2023BSTR_23452BS 1200R20G580JAP5.001,800.009,000.00
15SUM9,000.00
16116/09/2023BSTR_23453BS 1200R20G580JAP5.001,880.009,400.00
17SUM9,400.00
SV



DECREASE.xlsm
ABCDEFGHI
1ITEMDATEINV.NOBRANDTYPEORIGINQTY PRICETOTAL
2110/06/2023BSJ_23444BS 215/60R16ER30JAP4.00430.001,720.00
3SUM1,720.00
4110/06/2023BSJ_23445GO 1200R20AZ0026CHI2.00955.001,910.00
5SUM1,910.00
6115/09/2023BSJ_23446GO 1200R20AZ0026CHI2.00950.001,900.00
7215/09/2023BSJ_23446GO 1200R21AZ0027CHI3.001,000.003,000.00
8SUM4,900.00
9115/09/2023BSJ_23447BS 1200R20G580JAP1.002,000.002,000.00
10215/09/2023BSJ_23447BS 1200R20G580THI1.002,000.002,000.00
11315/09/2023BSJ_23447BS 1200R20R187THI1.002,000.002,000.00
12SUM6,000.00
SR



DECREASE.xlsm
ABCDEFGHIJ
1ITEMDATEINV.NOBRANDTYPEORIGINQTY PRICETOTALNOTICE
2115/06/2023VSTR_23444BS 750R16R230JAP1.00500.00500.00INV.NO BSTR_23448
3SUM500.00
4115/09/2023VSTR_23445GO 1200R20AZ0083CHI1.001,000.001,000.00INV.NO BSTR_23449
5SUM1,000.00
6115/09/2023VSTR_23446BS 1200R20G580JAP1.001,800.001,800.00INV NO BSTR_23450
7215/09/2023VSTR_23446BS 1200R20G580THI1.001,800.001,800.00INV NO BSTR_23450
8SUM3,600.00
9116/09/2023VSTR_23447BS 215/60R16ER30JAP4.00400.001,600.00INV NO BSTR_23451
10SUM1,600.00
11116/09/2023VSTR_23448BS 1200R20G580JAP1.001,800.001,800.00INV NO BSTR_23452
12SUM1,800.00
13116/09/2023VSTR_23449BS 1200R20G580JAP2.001,880.003,760.00INV NO BSTR_23453
14SUM3,760.00
VS



DECREASE.xlsm
ABCDEFGHIJ
2110/06/2023RSS_23222BS 215/60R16ER30JAP2.00430.00860.00INV.NO BSJ_23444
3SUM860.00
4110/06/2023BSJ_23445GO 1200R20AZ0026CHI1.00955.00955.00INV.NO BSJ_23445
5SUM955.00
6115/09/2023BSJ_23446GO 1200R20AZ0026CHI1.00950.00950.00INV.NO BSJ_23446
7215/09/2023BSJ_23446GO 1200R21AZ0027CHI2.001,000.002,000.00INV.NO BSJ_23446
8SUM2,950.00
RS



what I want matching columns D:F in SV sheet with columns D:F in VS sheet based on invoice number is in column(J)
if the invoice number in column J in s VS sheet is the same invoice number in column(C) in SV sheet then should subtract QTY for ID in columns D:F in SV sheet from VS sheet and change calculation for TOTAL column for each ID and SUM row for whole invoice number and should put word DONE in column J for adjacant ID cells to avoid subtraction every time repeatedly(meaning when there is DONE word shouldn't do any thing). and if there is the same ID for the same QTY then should delete the whole row for ID like 215/60R16 ER30 and whole row for SUM row if there is no another ID for the same invoice number .as to PRICE column will not change because will be the same

so in result in SV sheet should be as highlighted cells
DECREASE.xlsm
ABCDEFGHIJ
1ITEMDATEINV.NOBRANDTYPEORIGINQTY PRICETOTAL
2115/06/2023BSTR_23448BS 750R16R230JAP3.00500.001,500.00DONE
3215/06/2023BSTR_23448BS 700R16R230JAP2.00400.00800.00DONE
4SUM2,300.00
5115/09/2023BSTR_23449GO 1200R20AZ0026CHI1.00920.00920.00
6215/09/2023BSTR_23449GO 1200R20AZ0083CHI1.001,000.001,000.00DONE
7SUM1,920.00
8115/09/2023BSTR_23450BS 1200R20G580JAP9.001,800.0016,200.00DONE
9215/09/2023BSTR_23450BS 1200R20G580THI9.001,800.0016,200.00DONE
10315/09/2023BSTR_23450BS 1200R20R187THI10.001,800.0018,000.00
11SUM50,400.00
12116/09/2023BSTR_23452BS 1200R20G580JAP4.001,800.007,200.00DONE
13SUM7,200.00
14116/09/2023BSTR_23453BS 1200R20G580JAP3.001,880.005,640.00DONE
15SUM5,640.00
SV


also result in SR sheet bases on RS sheet with the same way as I did it in SV sheet.
expected data in SV,SR sheets contain 8500 rows .
thanks
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

Forum statistics

Threads
1,221,560
Messages
6,160,493
Members
451,653
Latest member
agata

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