Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Store array ??? | Excel Worksheet Functions | |||
How Do You Take Data Off A Sheet and Store It In An Array | Excel Programming | |||
Lookup and store in array | Excel Programming | |||
store chkbox.caption in array | Excel Programming | |||
Trying To Store Shapes/Objects to an array ?? | Excel Programming |