Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Dynamic multidimensional arrays

Give this a whirl... The perserve key word keeps the values that may already
be in the array. Without it any values in the array would be lost. Not
neseccary in this case...

Sub test()
Dim ary() As Integer

ReDim Preserve ary(10, 10)

ary(0, 0) = 1
ary(0, 1) = 2

End Sub

Note that you can still resize the array at any time but you can only resize
the last dimension...

--
HTH...

Jim Thomlinson


"ispy99" wrote:

All,

I am trying to write some VBA code for an excel application. I need to read
in a CSV file with a set number of fields but variable number of rows. I
have been able to open the file and read the contents, however I am having a
problem loading the data into an array. I believe I am simply not
understanding how to work with multidimensional dynamic arrays. In this case
I have two fields with a variable number of rows. I know in other languages
like Java I would instantiate a Vector (for example) and then add as many
elements as I needed. VBA seems to require knowing the size of the array
when it is created with Dim. Any suggestions?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
MultiDimensional Dynamic Arrays TomR29 Excel Programming 2 March 2nd 06 03:18 PM
Declare Multidimensional Arrays Alan Beban[_3_] Excel Programming 3 August 21st 03 02:40 AM
Declare Multidimensional Arrays Alan Beban[_3_] Excel Programming 0 August 20th 03 07:03 PM
Multidimensional Arrays - VBA Brent McIntyre Excel Programming 3 August 11th 03 09:01 AM
Multidimensional Arrays - VBA Brent McIntyre Excel Programming 14 August 8th 03 10:49 PM


All times are GMT +1. The time now is 10:28 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"