+ Reply to Thread
Results 1 to 2 of 2

Need to enlarge row size of array dynamically while preserving data in vba

  1. #1
    Registered User
    Join Date
    08-18-2014
    Location
    Myanmar
    MS-Off Ver
    2010
    Posts
    3

    Need to enlarge row size of array dynamically while preserving data in vba

    What I'm trying to do is to merge user selected CSV files with same header. I read the first csv file and put the header into an array. Then read the body data and put it into two dimension array like this.
    Following is incomplete code. I removed some unconcerned codes for clarity.

    Please Login or Register  to view this content.
    Problem is I can't enlarge the csvFinalData row size while preserving data according to this site.

    Only the upper bound of the last dimension in a multidimensional array can be changed when you use the Preserve keyword; if you change any of the other dimensions, or the lower bound of the last dimension, a run-time error occurs. Thus, you can use code like this:

    ReDim Preserve Matrix(10, UBound(Matrix, 2) + 1)

    But you cannot use this code:

    ReDim Preserve Matrix(UBound(Matrix, 1) + 1, 10)
    Is there any workaround to implement what I want to do? Any input would be greatly appreciated. Thanks for your precious time.

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

    Re: Need to enlarge row size of array dynamically while preserving data in vba

    Transpose the array, or use a 1D array of arrays instead so that you can resize and preserve.
    Remember what the dormouse said
    Feed your head

+ 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. Change size of Excel Data Table, dynamically
    By joshjpang in forum Excel General
    Replies: 10
    Last Post: 02-08-2013, 06:26 AM
  2. Dynamic array resizing and preserving data ?
    By djdave022002 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-16-2011, 09:32 AM
  3. Preserving size of linked excel bitmaps in word
    By msaz87 in forum Word Formatting & General
    Replies: 0
    Last Post: 06-07-2009, 09:08 PM
  4. Replies: 4
    Last Post: 05-08-2005, 11:06 AM
  5. [SOLVED] How do I enlarge chart size in document?
    By WilkesConcierge in forum Excel General
    Replies: 1
    Last Post: 02-24-2005, 01:06 PM

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