+ Reply to Thread
Results 1 to 5 of 5

Redim an array 2 dimensions

  1. #1
    Forum Contributor
    Join Date
    06-24-2013
    Location
    Berlin
    MS-Off Ver
    Excel 2007
    Posts
    188

    Redim an array 2 dimensions

    Hi Everyone,

    I iterate through a list and store the data in an array
    Please Login or Register  to view this content.
    This works fine, but I tried to have 2 dimensions to the array and It no longer works!


    Please Login or Register  to view this content.
    Would you have any ideas ?

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Redim an array 2 dimensions

    If you use Preserve when you Redim you can only change the last dimension. I assume the real code is more complicated as there is no need for Redim here at all, so you may want to consider transposing the array so that you resize the second dimension.
    Remember what the dormouse said
    Feed your head

  3. #3
    Forum Contributor
    Join Date
    06-24-2013
    Location
    Berlin
    MS-Off Ver
    Excel 2007
    Posts
    188

    Re: Redim an array 2 dimensions

    Thanks RomperStomper,

    Yes I simplified my problem, There is about 7000 records and 3 dimensions but if I understand the logic on 2 I figured I could do it on more.
    Basically per "row" in my array I have 3 info I want to store.
    ideally I wanted to do
    Dim preserve my array(x, 1 to 3)
    etc Now I understand I can only resize the last dimension.
    If I understand your suggestion properly I should do

    Redim preserve myarray(1 to 3, x)

    Thanks a lot for your help I am going to try that.

  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Redim an array 2 dimensions

    Depending on what you are doing with the array, you may also want to consider using an array of arrays. Then you only have one dimension for myArray so you can redim preserve as necessary, and simply assign an array to each element of myArray.

    Also, please don't forget to mark the thread solved if you are happy with the answer.

  5. #5
    Forum Contributor
    Join Date
    06-24-2013
    Location
    Berlin
    MS-Off Ver
    Excel 2007
    Posts
    188

    Re: Redim an array 2 dimensions

    Both of your suggestions worked!

    Thank you for your help.
    -Phil

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Redim on two dimentional array
    By msherifam01 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-05-2013, 02:26 AM
  2. Using the ReDim array function in a multidimensional array in excel
    By Doruli in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 11-05-2012, 01:43 PM
  3. Assign sheet value to array... and redim the array size
    By Orange.CL in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-27-2010, 07:18 AM
  4. ReDim Array
    By Viktor Ygdorff in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-10-2006, 11:09 AM
  5. ReDim Object array as parameter of Variant array
    By Peter T in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-10-2005, 10:06 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1