switching between workbooks

  • Thread starter Thread starter Bob Zimski
  • Start date Start date
B

Bob Zimski

I have a VBA that does some processing on a workbook and then opens another
workbook for some vlookups. The problem is that when I open the second
workbook it becomes the active workbook. What I would like is to somehow have
the workbook name stored in a variable and then open the second workbook.
Then, using the stored name of the first workbook, activate it. What set of
instructions do I use. I am in the process of learning VBA and don't have a
big enough vocabulary or mastery of the nomenclature yet.

Thanks
 
hi
based on what you posted, all you need is one line....
no need to store name as a variable.

workbooks("firstworkbook").activate 'sub your workbook name

put the line in when you want to switch back, probable just after you open
the second workbook.
regards
FSt1
 
Thanks for the insight. Further to my question, the reason I wanted to
capture the name in a variable, was because the original workbook name
changes every day. Therefore, I cannot hardcode the name.

Cheers
 
Dim ActCell as range
....
Set ActCell = activecell
'do a bunch of stuff

'go back
application.goto actcell
 
hi
still no problem...
Dim wb As Workbook
Set wb = ActiveWorkbook
Workbooks.Open Filename:= _
"C:\your\file\path\otherfile.xls"
wb.Activate

regards
FSt1
 

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

Back
Top