Results 1 to 3 of 3

Redim an array within an array

Threaded View

  1. #1
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Question Redim an array within an array

    Can I redim an array that is held within an array?

    I have (for example) 3 worksheets, and from each one I want to load 2 columns into an array.
    However I also want (I think) those 3 arrays to be contained within one array so that I can step through them easily.

    The code below will not run, but might better show what I am wanting;

    const sources_qty As Long = 3
    Dim source_arrays() as Variant ' the array to hold the others
    Dim array1() as variant
    Dim array2() as variant
    Dim array3() as variant
    
    Dim index as Long
    Dim ws as Worksheet
    
    ' Assign the arrays into the 'grouping' array
    ReDim source_arrays(sources_qty)
    source_arrays(1)=array1
    source_arrays(2)=array2
    source_arrays(3)=array3
    
    ' Load the arrays from the sheets
    for index = 1 to sources_qty
        Set ws = ThisWorkbook.Worksheets(Choose(index,"MyFirst","MySecond","MyThird"))
        ' the line below should redim the array HELD in source_arrays(1) (ie. array1), to be the same size as the number of used rows on 'ws'
        ReDim source_arrays(1)....... ? ws.usedrange.rows.count
    next
    'more code
    I'm just not sure how to reference the array within an array in order to redim it, (if it is possible?)

    thanks
    Last edited by Phil_V; 08-17-2009 at 09:11 AM.
    If you find the response helpful please click the scales in the blue bar above and rate it
    If you don't like the response, don't bother with the scales, they are not for you

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