+ Reply to Thread
Results 1 to 7 of 7

How to redim / resize a dynamic array with unknown elements

  1. #1
    Forum Contributor
    Join Date
    10-22-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    114

    How to redim / resize a dynamic array with unknown elements

    Hi vba gurus - I am hoping to get some help after trying many times without success.

    I have a range of data ("A1:D11"), the first row is a header row

    ----A-------B-------C--------D-------
    ----ID---Amount----ID----Amount-----
    ---101-----$10-----113-----$2--------
    ---102-----$45-----110-----$5--------
    ---103-----$78-----122-----$8--------
    ---104-----$93-----100----$45--------
    ---105-----$56-----101----$63--------
    ---106-----$42-----102----$92--------
    ---107----$552-----106----$84--------
    ---108-----$11-----107----$72--------
    ---109----$214-----105----$15--------
    ---110-----$11-----108----$61--------

    This is currently what I have in column F with blanks in between

    --F--
    101
    102


    105
    106
    107
    108

    110

    This is what I want in column F (Without Blanks)
    --F--
    101
    102
    105
    106
    107
    108
    110


    Please Login or Register  to view this content.

  2. #2
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: How to redim / resize a dynamic array with unknown elements

    Untested:-
    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: How to redim / resize a dynamic array with unknown elements

    Please Login or Register  to view this content.
    is a 2 d array=(10,4) is redim to (10,1)

  4. #4
    Forum Contributor
    Join Date
    10-22-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: How to redim / resize a dynamic array with unknown elements

    MickG, Thank you for you help. Works great.

  5. #5
    Forum Contributor
    Join Date
    10-22-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: How to redim / resize a dynamic array with unknown elements

    @AB33 - Thanks for you input. Could you explain your comment?

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: How to redim / resize a dynamic array with unknown elements

    Initially the array is loaded with
    Please Login or Register  to view this content.
    and then redim it to

    Please Login or Register  to view this content.
    which is(1 to 10, to 1 to 1).
    In effect, by redim in, you have reduced the 2nd upper dim in to a single column
    Last edited by AB33; 10-16-2013 at 06:05 PM.

  7. #7
    Forum Contributor
    Join Date
    10-22-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: How to redim / resize a dynamic array with unknown elements

    @AB - Thanks for the explanation.

+ 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] Array size unknown until the first "loop", how to correction dim/redim the array
    By menichols74 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-15-2013, 10:04 AM
  2. [SOLVED] Dynamic Array Fails to Redim Preserve
    By rodalsa1 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-07-2013, 09:52 AM
  3. dynamic array redim preserve: run-time error 9, Subscript out of range.
    By Broesel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-20-2009, 08:39 AM
  4. Resize array based on number of 'used' elements
    By John in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-22-2006, 02:30 AM
  5. how to redim more than one dimension in a multidimensional dynamic array?
    By lvcha.gouqizi in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-28-2005, 06:05 PM

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