Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default switching between workbooks

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default switching between workbooks

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


"Bob Zimski" wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default switching between workbooks

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

"FSt1" wrote:

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


"Bob Zimski" wrote:

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default switching between workbooks

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

'go back
application.goto actcell



Bob Zimski wrote:

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


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default switching between workbooks

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

regards
FSt1

"Bob Zimski" wrote:

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

"FSt1" wrote:

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


"Bob Zimski" wrote:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
switching between workbooks Jay Excel Programming 8 October 30th 08 03:56 PM
Switching between Workbooks Doekoe Excel Discussion (Misc queries) 0 May 5th 08 10:54 AM
Switching between workbooks Fan924 Excel Programming 3 October 11th 07 05:50 AM
Switching Between 2 workbooks using VBA Isit Ears[_2_] Excel Programming 1 October 17th 06 01:33 PM
switching between workbooks... safdarhassan Excel Programming 3 August 12th 06 01:06 PM


All times are GMT +1. The time now is 07:17 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"