Hi all,
I am looking for succinct vba code to refer to workbooks by partial name, and copy data from one to the other.
In the process, the user needs to have both workbooks ALREADY OPEN. The code I have now works, but only if the files are named exactly as listed in the code. So in reality, the users will name the files with a version date included.
1. Existing code that works when filenames are matching exactly:
Workbooks("sa_extract.xlsx").Worksheets(1).Range("A1:AM5000").Copy _
Workbooks("SA Process.xlsm").Worksheets("data").Range("A1")
2. Proposed code with wildcard * that I wish would work:
Workbooks("sa_extract*.xlsx").Worksheets(1).Range("A1:AM5000").Copy _
Workbooks("SA Process*.xlsm").Worksheets("data").Range("A1")
thanks
I am looking for succinct vba code to refer to workbooks by partial name, and copy data from one to the other.
In the process, the user needs to have both workbooks ALREADY OPEN. The code I have now works, but only if the files are named exactly as listed in the code. So in reality, the users will name the files with a version date included.
1. Existing code that works when filenames are matching exactly:
Workbooks("sa_extract.xlsx").Worksheets(1).Range("A1:AM5000").Copy _
Workbooks("SA Process.xlsm").Worksheets("data").Range("A1")
2. Proposed code with wildcard * that I wish would work:
Workbooks("sa_extract*.xlsx").Worksheets(1).Range("A1:AM5000").Copy _
Workbooks("SA Process*.xlsm").Worksheets("data").Range("A1")
thanks