toggling between 2 workbooks

  • Thread starter Thread starter excelnut1954
  • Start date Start date
E

excelnut1954

I'm copying data from one workbook to another. One of them will have a
static file name,
example test.xls
The other workbook, from which the macro is run, will have a variable
name, as it is changed each day, and given a new name based on the
date, example test 10-01-06.xls

Question is... in my macro, after I open up the other workbook
(text.xls), how can I switch control back to the original workbook?
Here's what I have so far:

'Opens the workbook w/ the static name
Workbooks.Open Filename:= Test.xls"
......more code......

'Control back to the original workbook. Then activates a worksheet.
'Remember - This workbook's name will change each day, w/ the date as
part of the new name.

Worksheets("sheet").Activate

Thanks,
J.O.
 
Create a workbook variable and set it to the activeworkbook before opening
the next.
Dim wb As Workbook
Set wb = ActiveWorkbook
Workbooks.Open....
BlahBlahBlah
wb.Activate
 
Back
Top