![]() |
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 |
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 |
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 |
All times are GMT +1. The time now is 12:03 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com