Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If I create 2 workbooks using workbooks.add - how do I refer to the first
inserted workbook as the second is active? Do I need to save the workbooks in order to be able to reference / activate them? Any pointers would be appreciated. Ta Andi |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dim bk1 as Workbook, bk2 as Workbook
set bk1 = workbooks.Add set bk2 = workbooks.add bk1.Activate msgbox "Click to continue" bk2.Activate -- Regards, Tom Ogilvy "Andibevan" wrote in message ... If I create 2 workbooks using workbooks.add - how do I refer to the first inserted workbook as the second is active? Do I need to save the workbooks in order to be able to reference / activate them? Any pointers would be appreciated. Ta Andi |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
No, all you need to do is to set a workbook object for each workbook as you
add them Set wb1 = Workbooks.Add Set wb2 = Workbooks.Add With wb1 .etc End With -- HTH RP (remove nothere from the email address if mailing direct) "Andibevan" wrote in message ... If I create 2 workbooks using workbooks.add - how do I refer to the first inserted workbook as the second is active? Do I need to save the workbooks in order to be able to reference / activate them? Any pointers would be appreciated. Ta Andi |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You can't with that as they are separate objects. You could try this
Dim aryWBs Redim aryWBs (1 To 2) Set aryWBs(1) = Workbooks.Add Set aryWBs(2) = Workbooks.Add For i = 1 to 2 Range("a1").Copy Destination = aryWBs(i).Worksheets("Sheet1").Range("a1:e1") Next i -- HTH RP (remove nothere from the email address if mailing direct) "Andibevan" wrote in message ... How do I cycle through wb1 and wb2:- I am trying this but ot no avail: For i = 1 to 2 Range("a1").Copy Destination = wb & i.Worksheets("Sheet1").Range("a1:e1") Next i "Bob Phillips" wrote in message ... No, all you need to do is to set a workbook object for each workbook as you add them Set wb1 = Workbooks.Add Set wb2 = Workbooks.Add With wb1 .etc End With -- HTH RP (remove nothere from the email address if mailing direct) "Andibevan" wrote in message ... If I create 2 workbooks using workbooks.add - how do I refer to the first inserted workbook as the second is active? Do I need to save the workbooks in order to be able to reference / activate them? Any pointers would be appreciated. Ta Andi |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'd answer, but doesn't look like you can see my responses. Hopefully Bob
will be back soon. -- Regards, Tom Ogilvy "Andibevan" wrote in message ... How do I cycle through wb1 and wb2:- I am trying this but ot no avail: For i = 1 to 2 Range("a1").Copy Destination = wb & i.Worksheets("Sheet1").Range("a1:e1") Next i "Bob Phillips" wrote in message ... No, all you need to do is to set a workbook object for each workbook as you add them Set wb1 = Workbooks.Add Set wb2 = Workbooks.Add With wb1 .etc End With -- HTH RP (remove nothere from the email address if mailing direct) "Andibevan" wrote in message ... If I create 2 workbooks using workbooks.add - how do I refer to the first inserted workbook as the second is active? Do I need to save the workbooks in order to be able to reference / activate them? Any pointers would be appreciated. Ta Andi |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Tom,
I saw your reply that successfully solved my original query - I also now realise that you can't cycle through workbooks as they are seperate objects, but you can assign each workbook to 1 array and then cycle through the array. Regards Andy "Tom Ogilvy" wrote in message ... I'd answer, but doesn't look like you can see my responses. Hopefully Bob will be back soon. -- Regards, Tom Ogilvy "Andibevan" wrote in message ... How do I cycle through wb1 and wb2:- I am trying this but ot no avail: For i = 1 to 2 Range("a1").Copy Destination = wb & i.Worksheets("Sheet1").Range("a1:e1") Next i "Bob Phillips" wrote in message ... No, all you need to do is to set a workbook object for each workbook as you add them Set wb1 = Workbooks.Add Set wb2 = Workbooks.Add With wb1 .etc End With -- HTH RP (remove nothere from the email address if mailing direct) "Andibevan" wrote in message ... If I create 2 workbooks using workbooks.add - how do I refer to the first inserted workbook as the second is active? Do I need to save the workbooks in order to be able to reference / activate them? Any pointers would be appreciated. Ta Andi |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
how do i create a macro to rename worksheets in excel? | Excel Discussion (Misc queries) | |||
How to open a new workbook and rename the workbook? | Excel Discussion (Misc queries) | |||
How to create a copy of a folder having five files in it, & rename | Excel Worksheet Functions | |||
How can I rename a Workbook? | Excel Programming | |||
Rename a workbook! | Excel Programming |