Consulting

Results 1 to 2 of 2

Thread: read data and put in array

  1. #1
    VBAX Tutor CCkfm2000's Avatar
    Joined
    May 2005
    Posts
    209
    Location

    read data and put in array

    hi all...

    what i want to do is to read all the data in columns A, B & C and store them in an array.

    the amount of data in columns will increase in time.

    column A will be a integer
    column B & C will be text


    please help

  2. #2
    VBAX Contributor
    Joined
    Jul 2005
    Posts
    169
    Location
    Do you need to [Read] the values in the range?

    Dim a
    a = Range("a1:c100").Value

    will give you a(1 To 100, 1 To 3) variant type 2D array...


    else
    Sub Sample()
    Dim a(), i As Long, ii As Long, rng As Range
    Set rng = Range("a1:c100")
    Redim a(1 To rng.Rows.Count, 1 To rng.Columns.Count)
    For i = 1 To rng.Columns.Count
          For ii = 1 To rng.Rows.Count
              a(ii, i) = rng.Cells(ii,i).Value
          Next
    Next
    Range("f1").Resize(UBound(a,1),UBound(a,2)) = a
    Erase a
    End Sub
    Last edited by jindon; 07-04-2006 at 08:46 PM.

Posting Permissions

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