Hi. Appreciate any help. Need a VBA code to copy paste sheet.range value FROM multiple workbooks (same table format in each sheet) located in same folder TO multiple worksheets in a master workbook. These worksheets in the master workbook are named with same name as the variable in the copy value. For clarity :
workbook1 (01012021.xlsx)
workbook2 (02012021.xlsx)
User will run the macro from Master workbook following these steps:
1. Choose folder path to the source workbooks (01012021.xlsx & 02012021.xlsx) as per above.
2. Do for workbook1 first. Copy sheet.range (A2:D2) which has the values for NAME1.
3. Pasting that copied sheet.range value to master workbook accordingly to the worksheet NAME1
4. Do again for next row copy sheet.range (A3:D3) which has the values for NAME2.
5. Pasting that copied sheet.range value to master workbook accordingly to the worksheet NAME2
6. Closed workbook1, activate workbook2
7. Repeat same process as step 2 to 5 pasting in master workbook accordingly.
The final result in Master workbook will be like below for sheet NAME1
and for sheet NAME2 as below
I will be glad to answer any question for further understanding. Thank you for your help.
workbook1 (01012021.xlsx)
01012021.xlsx | ||||||
---|---|---|---|---|---|---|
A | B | C | D | |||
1 | NAME | DATE | P | T | ||
2 | NAME1 | 1/1/2021 | 100 | 300 | ||
3 | NAME2 | 1/1/2021 | 2 | 2 | ||
SOURCE |
workbook2 (02012021.xlsx)
02012021.xlsx | ||||||
---|---|---|---|---|---|---|
A | B | C | D | |||
1 | NAME | DATE | P | T | ||
2 | NAME1 | 2/1/2021 | 300 | 300 | ||
3 | NAME2 | 2/1/2021 | 3 | 3 | ||
SOURCE |
User will run the macro from Master workbook following these steps:
1. Choose folder path to the source workbooks (01012021.xlsx & 02012021.xlsx) as per above.
2. Do for workbook1 first. Copy sheet.range (A2:D2) which has the values for NAME1.
3. Pasting that copied sheet.range value to master workbook accordingly to the worksheet NAME1
4. Do again for next row copy sheet.range (A3:D3) which has the values for NAME2.
5. Pasting that copied sheet.range value to master workbook accordingly to the worksheet NAME2
6. Closed workbook1, activate workbook2
7. Repeat same process as step 2 to 5 pasting in master workbook accordingly.
The final result in Master workbook will be like below for sheet NAME1
Master.xlsm | ||||||
---|---|---|---|---|---|---|
A | B | C | D | |||
1 | NAME | DATE | P | T | ||
2 | NAME1 | 1/1/2021 | 100 | 300 | ||
3 | NAME1 | 2/1/2021 | 300 | 300 | ||
NAME1 |
and for sheet NAME2 as below
Master.xlsm | ||||||
---|---|---|---|---|---|---|
A | B | C | D | |||
1 | NAME | DATE | P | T | ||
2 | NAME2 | 1/1/2021 | 2 | 2 | ||
3 | NAME2 | 2/1/2021 | 3 | 3 | ||
NAME2 |
I will be glad to answer any question for further understanding. Thank you for your help.