Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello all,
I want to create a dynamic array in visual basic for excel. Somehow I am doing something wrong with the following code. dim my_array as double dim my_integer as integer my_integer = 3 redim my_array(my_integer) as double this code doesn't seem to work in excel 97. Does anybody have an idea how this should be done? The value of the variable my_integer is not known at the start of the program. thanks in advance, Koos |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
dim my_array() as double
dim my_integer as integer my_integer = 3 redim my_array(my_integer) Should work. Declare my_array as a dynamic array by putting brackets after it in its initial declaration. You might have seen a variant redim'd without this type of declaration - but that is because variant can hold anything dim my_array as variant dim my_integer as integer my_integer = 3 redim my_array(my_integer) would have worked as well, but a variant takes up more space. -- Regards, Tom Ogilvy "Koos" wrote in message ... Hello all, I want to create a dynamic array in visual basic for excel. Somehow I am doing something wrong with the following code. dim my_array as double dim my_integer as integer my_integer = 3 redim my_array(my_integer) as double this code doesn't seem to work in excel 97. Does anybody have an idea how this should be done? The value of the variable my_integer is not known at the start of the program. thanks in advance, Koos |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks for the help,
the use of brackets was the trick ;-) Koos Tom Ogilvy wrote: dim my_array() as double dim my_integer as integer my_integer = 3 redim my_array(my_integer) Should work. Declare my_array as a dynamic array by putting brackets after it in its initial declaration. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Dynamic Arrays | Excel Discussion (Misc queries) | |||
Dynamic Range and arrays | Excel Discussion (Misc queries) | |||
Dynamic Range and arrays | Excel Worksheet Functions | |||
Dynamic arrays | New Users to Excel | |||
Dynamic Arrays | Excel Worksheet Functions |