Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Switching between open windows

I need to switch between 3 Open windows but two of them have variable names.

Wkbk1=macros resides here and the cells having the names of the other two
workbooks is on a sheet in this workbook
Wkbk2=the main workbook is being done in this workbook. Wkbk1 only has the
macro.
Wkbk2=this workbook has information to be copied into Wkbk2

Within Wkbk1:
Set Wkbk2 = Sheets("D Tab").Range("B11") (this cell has both the path and
Wkbk2 name)
Set Wkbk3 = Sheets("D Tab").Range("B35") (this cell has both the path and
Wkbk2 name)
Set Wkbk2Win= Sheets("D Tab").Range("B12") This cell has just the file name
in it.
Set Wkbk3Win= Sheets("D Tab").Range("B36") This cell has just the file name
in it.

The macro opens the workbooks correctly. But when I try to copy from Wkbk3
to Wkbk2, I cannot activate Wkbk2 to place the information in the proper
place. And, I suppose I will have trouble moving back to Wkbk3 when I need to
do more work there.

Here is where I am. I opened Wkbk1 and started the macro. The macro opens
Wkbk2 and prepares it for receiving the information from Wkbk3. The macro
then opens Wkbk3. The macro selects the information and copies it. At this
point I tried the following code:
Windows(Wkbk2Win).Activate




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Switching between open windows

Hi

As ALWAYS post your code for comments.

I would do something like this:

Dim Wkbk1 As Workbook
Dim Wkbk2 As Workbook
Dim Wkbk3 As Workbook

Set Wkbk1 = ThisWorkbook
Set Wkbk2 = Workbooks.Open _
(Filename:=Wkbk1.Sheets("D Tab").Range("B11").Value)
Set Wkbk3 = Workbooks.Open _
(Filename:=Wkbk1.Sheets("D Tab").Range("B35").Value)

Wkbk3.Sheets("Sheet1").Range("A1:B10").Copy _
Destination:=Wkbk2.Sheets("Sheet1").Range("A1")

Wkbk2.Activate

Hopes this helps

---
Per

"iashorty" skrev i meddelelsen
...
I need to switch between 3 Open windows but two of them have variable
names.

Wkbk1=macros resides here and the cells having the names of the other two
workbooks is on a sheet in this workbook
Wkbk2=the main workbook is being done in this workbook. Wkbk1 only has the
macro.
Wkbk2=this workbook has information to be copied into Wkbk2

Within Wkbk1:
Set Wkbk2 = Sheets("D Tab").Range("B11") (this cell has both the path and
Wkbk2 name)
Set Wkbk3 = Sheets("D Tab").Range("B35") (this cell has both the path and
Wkbk2 name)
Set Wkbk2Win= Sheets("D Tab").Range("B12") This cell has just the file
name
in it.
Set Wkbk3Win= Sheets("D Tab").Range("B36") This cell has just the file
name
in it.

The macro opens the workbooks correctly. But when I try to copy from Wkbk3
to Wkbk2, I cannot activate Wkbk2 to place the information in the proper
place. And, I suppose I will have trouble moving back to Wkbk3 when I need
to
do more work there.

Here is where I am. I opened Wkbk1 and started the macro. The macro opens
Wkbk2 and prepares it for receiving the information from Wkbk3. The macro
then opens Wkbk3. The macro selects the information and copies it. At this
point I tried the following code:
Windows(Wkbk2Win).Activate





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Switching between open windows

Worked wonderfully, thanks


"Per Jessen" wrote:

Hi

As ALWAYS post your code for comments.

I would do something like this:

Dim Wkbk1 As Workbook
Dim Wkbk2 As Workbook
Dim Wkbk3 As Workbook

Set Wkbk1 = ThisWorkbook
Set Wkbk2 = Workbooks.Open _
(Filename:=Wkbk1.Sheets("D Tab").Range("B11").Value)
Set Wkbk3 = Workbooks.Open _
(Filename:=Wkbk1.Sheets("D Tab").Range("B35").Value)

Wkbk3.Sheets("Sheet1").Range("A1:B10").Copy _
Destination:=Wkbk2.Sheets("Sheet1").Range("A1")

Wkbk2.Activate

Hopes this helps

---
Per

"iashorty" skrev i meddelelsen
...
I need to switch between 3 Open windows but two of them have variable
names.

Wkbk1=macros resides here and the cells having the names of the other two
workbooks is on a sheet in this workbook
Wkbk2=the main workbook is being done in this workbook. Wkbk1 only has the
macro.
Wkbk2=this workbook has information to be copied into Wkbk2

Within Wkbk1:
Set Wkbk2 = Sheets("D Tab").Range("B11") (this cell has both the path and
Wkbk2 name)
Set Wkbk3 = Sheets("D Tab").Range("B35") (this cell has both the path and
Wkbk2 name)
Set Wkbk2Win= Sheets("D Tab").Range("B12") This cell has just the file
name
in it.
Set Wkbk3Win= Sheets("D Tab").Range("B36") This cell has just the file
name
in it.

The macro opens the workbooks correctly. But when I try to copy from Wkbk3
to Wkbk2, I cannot activate Wkbk2 to place the information in the proper
place. And, I suppose I will have trouble moving back to Wkbk3 when I need
to
do more work there.

Here is where I am. I opened Wkbk1 and started the macro. The macro opens
Wkbk2 and prepares it for receiving the information from Wkbk3. The macro
then opens Wkbk3. The macro selects the information and copies it. At this
point I tried the following code:
Windows(Wkbk2Win).Activate






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
cannot open exel from windows xp in windows vista and visa versa lildiana New Users to Excel 4 February 25th 09 07:26 PM
Switching between open workbooks RJC[_2_] Excel Programming 6 April 15th 08 04:41 PM
switching out of Excel with userform open Smallweed Excel Programming 3 June 5th 07 03:33 PM
problems switching speadsheets in excel 2000 using windows xp berger Excel Discussion (Misc queries) 0 October 19th 05 10:39 PM
Open email windows can't open, excel shreadsheet file .xls ? skiz Excel Discussion (Misc queries) 0 October 2nd 05 07:03 PM


All times are GMT +1. The time now is 08:55 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"