Results 1 to 15 of 15

Thread: How to read data from a worksheet into an array in a module?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    VBAX Mentor tstav's Avatar
    Joined
    Feb 2008
    Location
    Athens
    Posts
    350
    Location
    Quote Originally Posted by cgphung
    I imported a set of data in a work sheet and need to use it as an array for all the macros the I used in the workbook. Just how do I make this work?
    Suppose your data range is Range("A1:B3"). (You change it to whatever your data range is).
    Declare a dynamic Array of variant data type.
    Dimension it according to the RowsNumber and ColumnsNumber of your range.
    Assign the range to this Array.
    [vba]Dim Arr() As Variant
    Sub RangeToArray()
    Dim R as Range
    Set R = Range("A1:B3")
    ReDim Arr(R.Rows.Count, R.Columns.Count)
    Arr = R
    End Sub[/vba]
    Last edited by tstav; 03-12-2008 at 12:11 AM.
    He didn't know it was impossible, so he did it. (Jean Cocteau)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •