+ Reply to Thread
Results 1 to 7 of 7

Using the ReDim array function in a multidimensional array in excel

  1. #1
    Registered User
    Join Date
    10-30-2012
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    44

    Using the ReDim array function in a multidimensional array in excel

    Hello,

    I am working with multidimensional arrays in excel
    Is it any way I can apply the Redim function to them

    For example I have an array ReplacementSchedule(,6)
    I know the number of columns but I learn dynamically the number of rows

    Ideally I would have liked to be able to say ReDim(ReplacementSchedule(NumRows,6))
    However that does not work

    Any ideas of how to install dynamic multidimensional arrays in excel?

    Regards
    Dora

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Using the ReDim array function in a multidimensional array in excel

    You can only re-dim the final dimension of a dynamic array. So in your case, the number of columns rather than rows.

    There are numerous approaches to a solution to this but they would be dependant on your scenario. Likely solutions would be multiple 1d arrays, 1 single array for rows and multiple 1d arrays for columns so you have an array of arrays, you could utilise a collection object in the same way, or you could transpose your data so you have rows as columns and columns as rows.

    Edit: After reading Norie's comments, I think I got the wrong end of the stick with this one. To clarify, you can only redim the last dimension of an array once it's been dimensioned
    Last edited by Kyle123; 11-05-2012 at 08:36 AM.

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    Dora

    Does this work?
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  4. #4
    Registered User
    Join Date
    10-30-2012
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    44

    Re: Using the ReDim array function in a multidimensional array in excel

    Hello Thanks
    But How do I define a dynamic multidimenasional array
    Dim ReplacementSchedule(,1 To 6) As Variant that does no work

  5. #5
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Using the ReDim array function in a multidimensional array in excel

    Please Login or Register  to view this content.

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Using the ReDim array function in a multidimensional array in excel

    Dora

    If you mean you don't know the first dimension then it's not possible to omit it.

    Why not redim the array when you know the no of rows?

  7. #7
    Registered User
    Join Date
    10-30-2012
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    44

    Re: Using the ReDim array function in a multidimensional array in excel

    Thanks for your suggetsion it works now

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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