+ Reply to Thread
Results 1 to 4 of 4

Redim 2 dimensional array

  1. #1
    Registered User
    Join Date
    01-01-2005
    MS-Off Ver
    2007
    Posts
    368

    Redim 2 dimensional array

    Hi,

    See attached file.

    I am having a problem with using REDIM on a two dimentional array.

    Please Login or Register  to view this content.
    Since I only have 3 values on column E, I should get only 3 records on my array.

    What do I need to change to make it work?

    Regards,
    Elio Fernandes
    Attached Files Attached Files
    Last edited by efernandes67; 01-10-2011 at 10:38 AM.

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Redim 2 dimensional array

    Don't forget Excel Help:
    If you use the Preserve keyword, you can resize only the last array dimension
    You could turn everything round:
    Please Login or Register  to view this content.
    or have two arrays.
    Last edited by StephenR; 01-10-2011 at 08:03 AM.

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Redim 2 dimensional array

    edit: below posted at time of above edit with code hence duplication

    As above you must reverse the dimensions - and blanks are interpreted as numeric type, so modifying your code (assuming this hypothetical):

    Please Login or Register  to view this content.
    So your array will end up as (0 To 1, 0 To 2) rather than (0 To 2, 0 To 1)

    edit:
    Preserve can be expensive so it might be better to oversize the Array (ie to Match iteration - 0 To 4, 0 To 1) and ReDim once at the end based on cnt to remove surplus.
    Last edited by DonkeyOte; 01-10-2011 at 08:06 AM.

  4. #4
    Registered User
    Join Date
    01-01-2005
    MS-Off Ver
    2007
    Posts
    368

    Re: Redim 2 dimensional array

    It's working.

    Thanks,
    Elio Fernandes

+ 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