Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
cannot open exel from windows xp in windows vista and visa versa | New Users to Excel | |||
Switching between open workbooks | Excel Programming | |||
switching out of Excel with userform open | Excel Programming | |||
problems switching speadsheets in excel 2000 using windows xp | Excel Discussion (Misc queries) | |||
Open email windows can't open, excel shreadsheet file .xls ? | Excel Discussion (Misc queries) |