Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I need to switch between 2 open files in a macro. I know the name of one
file but not the other. What code can I use to activate the workbook that I don't know the name of? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Maybe
Activewindow.ActivateNext but it wouldn't be my first choice as it depends on there being only two workbooks open. Can you use the macros in the first workbook to open the second during execution? Since you don't know the file name, I assume the user has to open the second book. Sub test() Dim wkbTest As Workbook Dim varFName As Variant varFName = Application.GetOpenFilename If varFName = False Then End Set wkbTest = Workbooks.Open(Filename:=varFName) End Sub Then you can use the object variable, wkbTest (change variable name if you like) to refer to the second book. wkbTest.Worksheets("Sheet1").Range("A1").Value = 5 "Lynn" wrote: I need to switch between 2 open files in a macro. I know the name of one file but not the other. What code can I use to activate the workbook that I don't know the name of? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Open unknown file name | Excel Programming | |||
Paste sheet to new file with unknown file name - VBA | Excel Programming | |||
Linked file in same folder but unknown path | Excel Programming | |||
refer to unknown window name | Excel Programming | |||
How to Activate unknown file name | Excel Programming |