Re: Array from row in work***
- From: "Scott Collier" <nospamplease@xxxxxxxxxxxx>
- Date: Fri, 9 Jun 2006 02:06:54 +0800
Probably due to this section
'Populate the array
Do While ActiveCell.Offset(0, i).Value <> ""
Products(i) = ActiveCell.Offset(0, i).Value
i = i + 1
Loop
The "i" in Products(i) - might be getting to big - worth investigating.
Scott
"Colin Nederkoorn" <sudonim@xxxxxxxxx> wrote in message
news:1149780648.512766.203020@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi All,
I am trying to dynamically copy named sheets to a new workbook. The
following works perfectly:
Products = Array("Apple", "Banana", "Orange")
Sheets(Products).Copy
This copies the worksheets Apple, Banana and Orange to a new workbook.
What I am trying to do is dynamically populate the array. I have the
following code to do so:
Dim Products
i = 1
'Get the number of products
Do While ActiveCell.Offset(0, i).Value <> ""
i = i + 1
Loop
'Redefine the array size to number of products
ReDim Products((i-1))
'Reset the counter
i = 0
'Populate the array
Do While ActiveCell.Offset(0, i).Value <> ""
Products(i) = ActiveCell.Offset(0, i).Value
i = i + 1
Loop
Sheets(Products).Copy
- The code above should redefine the array to add Apple, Banana and
Orange in to position 1, 2, and 3 in the array respectively. The error
message I receive from: Sheets(Products).Copy is:
Run-time error '9':
Subscript out of range
.
- References:
- Array from row in work***
- From: Colin Nederkoorn
- Array from row in work***
- Prev by Date: Re: Select a *** by name in a macro
- Next by Date: RE: Renaming a range
- Previous by thread: Array from row in work***
- Next by thread: Re: Set Path for GetSaveAsFilename
- Index(es):