I am to export 3 excel workbooks from a database, which are all named based on the material located within various cells of the first sheet in their respective workbooks. I would like to combine all of the workbooks into one. Workbook 1 (the master), is named (not saved) given the values in cells A2:C2. The kicker, is that I would like to be able to run this with more than the 3 necessary workbooks open at the same time. I know that the fist tab of the master workbook will always be called "summary", so this is what i have so far:
-None of the workbooks are saved. They are simply just exported.
-I do not know where the code is that is dynamically saving the report. I do not think that it is done in excel, it is built into the database, I assume. However, I am not an experienced developer, so I truly do not know.
-All of the needed workbooks are already open. However, there could me more irrelevant workbooks open at this time.
-The non-master workbooks consist only of one sheet. I simply just need to move the first sheet of each of the 2nd and 3rd workbooks into the master workbook (at the end).
Sub CombineWorkbooks()
'Find the "Master Workbook"
Dim WB As Workbook
For Each WB In Workbooks
WB.Activate
If ActiveSheet.Name = "Summary" Then
Range("a1").Select 'This is the only way that i could figure out how to make the loop stop once it found the master workbook. - Any suggestions on other ways to do this would be awesome.
Else
End If
Next WB
'Retreive the dynamic name of the "Master" workbook
Master = ActiveWorkbook.Name
'Now, I could write another macro, which would reference the name of the master and combine.
However, I would like to be able to do this all in one if possible. As stated above, I would like for this to run, even if there are additional workbooks open.
Thank you for your quick response and please let me know if you need anything else!