I'm desperate! So here's the issue:
I have two workbooks that are updated regularly. The workbook names won't change from one update to the next, except for the value of a date at the end of the name (format 01Jan2011). In other words, one workbook is named "FirstWorkbook 13Sep2011.xlsx" and the other "SecondWorkbook 21Aug2011.xlsm." I want to use information from one workbook to update a table on the other. I have two branches of code, one collecting the data I want from the first WB, and the other displaying it in the second. My problem is that I can't figure out how to go from one WB to the other. I've searched for about 2 hours (Ack!) for something useful, with no luck. I've also tried a bajillion things, but here are a few examples of what did NOT work:
myWB = Windows("FirstWorkbook #########.xlsm").Name
mySummary = Windows("SecondWorkbook #########.xlsx").Name
I also tried replacing "Windows" with "Workbooks" and still had trouble.
I've also tried creating a new sub and calling it:
Sub GetFirstWorkbook ()
Dim WB As Workbook
For Each WB In Workbooks
If WB.Name Like "FirstWorkbook #########.xlsm" Then GoTo ActivateIt
Next WB
Exit Sub
ActivateIt:
Windows(WB.Name).Activate
End Sub
This works ok in isolation (during the data-gathering part), but doesn't work when I try to use it to go from one WB to the other.
There are probably more variations I've attempted, but my brain is fried like an egg and I can't remember them all. I'd LOVE help, and be eternally grateful to anyone who can save me from this nastiness.
Thank you!!
I have two workbooks that are updated regularly. The workbook names won't change from one update to the next, except for the value of a date at the end of the name (format 01Jan2011). In other words, one workbook is named "FirstWorkbook 13Sep2011.xlsx" and the other "SecondWorkbook 21Aug2011.xlsm." I want to use information from one workbook to update a table on the other. I have two branches of code, one collecting the data I want from the first WB, and the other displaying it in the second. My problem is that I can't figure out how to go from one WB to the other. I've searched for about 2 hours (Ack!) for something useful, with no luck. I've also tried a bajillion things, but here are a few examples of what did NOT work:
myWB = Windows("FirstWorkbook #########.xlsm").Name
mySummary = Windows("SecondWorkbook #########.xlsx").Name
I also tried replacing "Windows" with "Workbooks" and still had trouble.
I've also tried creating a new sub and calling it:
Sub GetFirstWorkbook ()
Dim WB As Workbook
For Each WB In Workbooks
If WB.Name Like "FirstWorkbook #########.xlsm" Then GoTo ActivateIt
Next WB
Exit Sub
ActivateIt:
Windows(WB.Name).Activate
End Sub
This works ok in isolation (during the data-gathering part), but doesn't work when I try to use it to go from one WB to the other.
There are probably more variations I've attempted, but my brain is fried like an egg and I can't remember them all. I'd LOVE help, and be eternally grateful to anyone who can save me from this nastiness.
Thank you!!