Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Dimensioning Arrays
I think I need to use an array, but it insists I use 'constant' expressions
when declaring the array, but I want to change its size depending on the data in use. ReDim would seem an appropriate option, but that too wants constant expressions and hence I cannot use variables to define the required size. Is this a limitation of VBA (I find hard to believe) or have I missed something obvious? Thank Peter M |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Dimensioning Arrays
Peter,
You can use a variable. This little example shows that you can do that, using an element of the same array itself Dim av() As Long ReDim av(3) av(0) = 1 av(1) = 2 av(2) = 3 av(3) = 4 ReDim Preserve av(av(3)) av(4) = 9 MsgBox av(4) -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Peter M" wrote in message ... I think I need to use an array, but it insists I use 'constant' expressions when declaring the array, but I want to change its size depending on the data in use. ReDim would seem an appropriate option, but that too wants constant expressions and hence I cannot use variables to define the required size. Is this a limitation of VBA (I find hard to believe) or have I missed something obvious? Thank Peter M |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Dimensioning Arrays
Declare the array without dimensions first:
Dim arr() ReDim arr(1 to 3) Alan Beban Peter M wrote: I think I need to use an array, but it insists I use 'constant' expressions when declaring the array, but I want to change its size depending on the data in use. ReDim would seem an appropriate option, but that too wants constant expressions and hence I cannot use variables to define the required size. Is this a limitation of VBA (I find hard to believe) or have I missed something obvious? Thank Peter M |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
VBA arrays | Excel Discussion (Misc queries) | |||
Arrays | Excel Worksheet Functions | |||
Use of IF with arrays | Excel Worksheet Functions | |||
Range Naming, dimensioning | New Users to Excel | |||
Need help with arrays (I think) | Excel Worksheet Functions |