Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 128
Default Create and Rename workbook

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Create and Rename workbook

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Create and Rename workbook

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Create and Rename workbook

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Create and Rename workbook

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 128
Default Create and Rename workbook

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
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
how do i create a macro to rename worksheets in excel? Waki Excel Discussion (Misc queries) 6 January 28th 10 04:06 PM
How to open a new workbook and rename the workbook? pokdbz Excel Discussion (Misc queries) 3 December 26th 07 03:37 PM
How to create a copy of a folder having five files in it, & rename Matthews Excel Worksheet Functions 1 November 7th 06 03:42 PM
How can I rename a Workbook? Mac Lingo[_2_] Excel Programming 2 April 23rd 05 09:24 PM
Rename a workbook! aiyer[_22_] Excel Programming 1 May 12th 04 05:12 PM


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