Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default How to store the reference of Workbooks in an array.

I have opend four workbooks. Now i wanted to store reference of each workbook
in an array so that i can use them later. Please see the below code, it is
throwing an error. Here i have opened a workbooks and stored it reference in
wb, now when i try to store wb in an array, it throws error.

Set arrWorkbooks(i)= wb
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default How to store the reference of Workbooks in an array.

Hi

Maybe this will help you:

Sub test()
Dim WbArr()
Dim i As Long
ReDim WbArr(Application.Workbooks.Count)
For Each wb In Application.Workbooks
WbArr(i) = wb.Name
i = i + 1
Next
End Sub

Regards,
Per

"Store a reference of a excel workbook"
soft.com skrev i
meddelelsen ...
I have opend four workbooks. Now i wanted to store reference of each
workbook
in an array so that i can use them later. Please see the below code, it is
throwing an error. Here i have opened a workbooks and stored it reference
in
wb, now when i try to store wb in an array, it throws error.

Set arrWorkbooks(i)= wb


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default How to store the reference of Workbooks in an array.

Hi Per Jessen, Thanks for your reply. In the below code you are storing the
name of the workbook in the array not references to the workbooks. How can i
reference a particular workbook with this array and copy the cells from that
workbook to another workbook?

"Per Jessen" wrote:

Hi

Maybe this will help you:

Sub test()
Dim WbArr()
Dim i As Long
ReDim WbArr(Application.Workbooks.Count)
For Each wb In Application.Workbooks
WbArr(i) = wb.Name
i = i + 1
Next
End Sub

Regards,
Per

"Store a reference of a excel workbook"
soft.com skrev i
meddelelsen ...
I have opend four workbooks. Now i wanted to store reference of each
workbook
in an array so that i can use them later. Please see the below code, it is
throwing an error. Here i have opened a workbooks and stored it reference
in
wb, now when i try to store wb in an array, it throws error.

Set arrWorkbooks(i)= wb



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default How to store the reference of Workbooks in an array.

Hi

Activate the destination workbook and use this:

Workbooks(WbArr(i)).Sheets("Sheet1").Range("A1:A10 ").Copy _
Destination:= Sheets("Sheet2").Range("A1")

Regards,
Per

"Store a reference of a excel workbook"
soft.com skrev i
meddelelsen ...
Hi Per Jessen, Thanks for your reply. In the below code you are storing
the
name of the workbook in the array not references to the workbooks. How can
i
reference a particular workbook with this array and copy the cells from
that
workbook to another workbook?

"Per Jessen" wrote:

Hi

Maybe this will help you:

Sub test()
Dim WbArr()
Dim i As Long
ReDim WbArr(Application.Workbooks.Count)
For Each wb In Application.Workbooks
WbArr(i) = wb.Name
i = i + 1
Next
End Sub

Regards,
Per

"Store a reference of a excel workbook"
soft.com skrev i
meddelelsen ...
I have opend four workbooks. Now i wanted to store reference of each
workbook
in an array so that i can use them later. Please see the below code, it
is
throwing an error. Here i have opened a workbooks and stored it
reference
in
wb, now when i try to store wb in an array, it throws error.

Set arrWorkbooks(i)= wb




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,069
Default How to store the reference of Workbooks in an array.

Or, we could use an object variable array and store references to the
workbooks themselves:

Sub test()
Dim WbArr() As Workbook, wb
Dim i As Long
ReDim WbArr(Application.Workbooks.Count)
For Each wb In Application.Workbooks
Set WbArr(i) = wb
MsgBox WbArr(i).FullName
i = i + 1
Next
End Sub

Be sure to free the memory later with
Set WbArr() = Nothing

Hope this helps,

Hutch

"Store a reference of a excel workbook" wrote:

Hi Per Jessen, Thanks for your reply. In the below code you are storing the
name of the workbook in the array not references to the workbooks. How can i
reference a particular workbook with this array and copy the cells from that
workbook to another workbook?

"Per Jessen" wrote:

Hi

Maybe this will help you:

Sub test()
Dim WbArr()
Dim i As Long
ReDim WbArr(Application.Workbooks.Count)
For Each wb In Application.Workbooks
WbArr(i) = wb.Name
i = i + 1
Next
End Sub

Regards,
Per

"Store a reference of a excel workbook"
soft.com skrev i
meddelelsen ...
I have opend four workbooks. Now i wanted to store reference of each
workbook
in an array so that i can use them later. Please see the below code, it is
throwing an error. Here i have opened a workbooks and stored it reference
in
wb, now when i try to store wb in an array, it throws error.

Set arrWorkbooks(i)= wb



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
Store array ??? piero Excel Worksheet Functions 4 September 16th 09 04:39 PM
How Do You Take Data Off A Sheet and Store It In An Array Raleigh Excel Programming 2 January 17th 06 08:47 PM
Lookup and store in array kanuvas[_7_] Excel Programming 1 November 9th 05 10:43 AM
store chkbox.caption in array ilyaskazi[_19_] Excel Programming 3 June 7th 05 05:29 PM
Trying To Store Shapes/Objects to an array ?? Dan Thompson Excel Programming 0 September 21st 04 08:37 PM


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