toggling between 2 workbooks

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.
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top