![]() |
dynamic arrays in excel
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 |
dynamic arrays in excel
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 |
dynamic arrays in excel
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. |
All times are GMT +1. The time now is 02:56 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com