hello everyone...
I'm looking for a solution for a VBA solution for my scenario which currently can be done by using formula (thank you in advance) :-
My scenario:
1. I need to transfer data from workbook A and workbook B into workbook C. based on two criteria for each selected column in workbook C
criteria 1: the header in column B,C and D in workbook C
criteria 2: the code in column A in workbook C
Example:-
data source workbook A:
data source workbook B:
output workbook C:
I will do a formula to lookup refer to column A into column B,C and D, as you noticed the sequence of the header and code is different too.
The formula I use:
for column B =XLOOKUP(A:A,[workbook A]Sheet1!$A:$A,[workbook A]Sheet1!$C:$C)
for column C =XLOOKUP(A:A,[workbook A]Sheet1!$A:$A,[workbook A]Sheet1!$B:$B)
for column D =XLOOKUP(A:A,[workbook B]Sheet1!$A:$A,[workbook A]Sheet1!$B:$B)
I am looking for a VBA solution that can:-
1. Browse the data source workbook A and workbook B without need to manually open the file
2. Copy paste value the data from workbook A and workbook B into workbook C based on below criteria into the empty cell in range B2:D7
criteria 1: the header in column B,C and D in workbook C
criteria 2: the code in column A in workbook C
3. If the data is not found for the code, for example data for code 113 is not found in workbook A, cell B2 remain empty and continue to work on code 116, so on and on.
4. At the end of the macro:-
a. provide a message if any column is not found, if successfully found all columns, provide a successful message.
b. close workbook A and workbook B
I'm looking for a solution for a VBA solution for my scenario which currently can be done by using formula (thank you in advance) :-
My scenario:
1. I need to transfer data from workbook A and workbook B into workbook C. based on two criteria for each selected column in workbook C
criteria 1: the header in column B,C and D in workbook C
criteria 2: the code in column A in workbook C
Example:-
data source workbook A:
data source workbook B:
output workbook C:
I will do a formula to lookup refer to column A into column B,C and D, as you noticed the sequence of the header and code is different too.
The formula I use:
for column B =XLOOKUP(A:A,[workbook A]Sheet1!$A:$A,[workbook A]Sheet1!$C:$C)
for column C =XLOOKUP(A:A,[workbook A]Sheet1!$A:$A,[workbook A]Sheet1!$B:$B)
for column D =XLOOKUP(A:A,[workbook B]Sheet1!$A:$A,[workbook A]Sheet1!$B:$B)
I am looking for a VBA solution that can:-
1. Browse the data source workbook A and workbook B without need to manually open the file
2. Copy paste value the data from workbook A and workbook B into workbook C based on below criteria into the empty cell in range B2:D7
criteria 1: the header in column B,C and D in workbook C
criteria 2: the code in column A in workbook C
3. If the data is not found for the code, for example data for code 113 is not found in workbook A, cell B2 remain empty and continue to work on code 116, so on and on.
4. At the end of the macro:-
a. provide a message if any column is not found, if successfully found all columns, provide a successful message.
b. close workbook A and workbook B