hi
I have two sheets should match sheet2 with sheet1 based on columns B,C,D toghether and copy the values to last two empty columns contain headers (purchase and sales) .so in this case after match the data between two sheets it will populate the values in COL E,F in sheet2 and if I run macro again will copy to next empty columns PURCHASE , SALES (H,I) an so on . every time run the macro should search for empty columns(PURCHASE , SALES) and populate the values based on what is existed in sheet1.
I put the expected result should be in sheet2 after matching with sheet1 . with considering the data in sheet1 are increasable and the inserted columns also are increasable in sheet2
sheet1
sheet2 before
sheet2 after
I have two sheets should match sheet2 with sheet1 based on columns B,C,D toghether and copy the values to last two empty columns contain headers (purchase and sales) .so in this case after match the data between two sheets it will populate the values in COL E,F in sheet2 and if I run macro again will copy to next empty columns PURCHASE , SALES (H,I) an so on . every time run the macro should search for empty columns(PURCHASE , SALES) and populate the values based on what is existed in sheet1.
I put the expected result should be in sheet2 after matching with sheet1 . with considering the data in sheet1 are increasable and the inserted columns also are increasable in sheet2
sheet1
pop.xlsm | ||||||||
---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | |||
1 | DATE | COMMIDETY | TYPE | ORIGIN | PURCHASE | SALES | ||
2 | 1/7/2021 | FR | BANANA | SO | 55 | 5 | ||
3 | 1/8/2021 | FR | BANANA | SO1 | 10 | |||
4 | 1/10/2021 | VEG | TOMATO | EG | 5 | |||
5 | 1/17/2021 | FO1 | TUNE160G | SP | 22 | 5 | ||
6 | 1/18/2021 | FO1 | TUNE160G | PO | 10 | 10 | ||
7 | 1/18/2021 | FO1 | TUNE160G | SPL | 5 | - | ||
SHEET1 |
sheet2 before
pop.xlsm | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | |||
1 | ITEM | COMMIDETY | TYPE | ORIGIN | PURCHASE | SALES | BALANCE | PURCHASE | SALES | BALANCE | PURCHASE | SALES | BALANCE | PURCHASE | SALES | BALANCE | ||
2 | 1 | FR | BANANA | SO | 0 | 0 | 0 | 0 | ||||||||||
3 | 2 | FR | BANANA | SO1 | 0 | 0 | 0 | 0 | ||||||||||
4 | 3 | FO1 | TUNE160G | SP | 0 | 0 | 0 | 0 | ||||||||||
5 | 4 | FO1 | TUNE160G | PO | 0 | 0 | 0 | 0 | ||||||||||
6 | 5 | VEG | TOMATO | EG | 0 | 0 | 0 | 0 | ||||||||||
7 | 6 | FO1 | TUNE160G | SPL | 0 | 0 | 0 | 0 | ||||||||||
SHEET2 |
Cell Formulas | ||
---|---|---|
Range | Formula | |
P2:P7,M2:M7,J2:J7,G2:G7 | G2 | =E2-F2 |
sheet2 after
pop.xlsm | ||||||||
---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | |||
1 | ITEM | COMMIDETY | TYPE | ORIGIN | PURCHASE | SALES | ||
2 | 1 | FR | BANANA | SO | 55 | 5 | ||
3 | 2 | FR | BANANA | SO1 | 10 | |||
4 | 3 | FO1 | TUNE160G | SP | 22 | 5 | ||
5 | 4 | FO1 | TUNE160G | PO | 10 | 10 | ||
6 | 5 | VEG | TOMATO | EG | 5 | |||
7 | 6 | FO1 | TUNE160G | SPL | 5 | |||
EXPECTED RESULT |