Results 1 to 2 of 2
  1. #1
    5 Star Lounger
    Join Date
    Mar 2001
    Thanked 0 Times in 0 Posts

    Copying from array (2002)

    I recall that there is a method of copying data en masse from a VBA array into a worksheet. I believe it requires a Variant, but can't recall the precise code that would copy the array of data, starting from A1 for example? Any ideas? Andy.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 31 Times in 31 Posts

    Re: Copying from array (2002)

    Since a range consists of rows and columns, the trick is to use a two-dimensional array, even if you want to fill only a single column. Example:

    Sub FillFromArray()
    Dim arrValues(1 To 10, 1 To 1)
    Dim i As Integer
    ' Fill the array
    For i = 1 To 10
    arrValues(i, 1) = "Item number " & i
    Next i
    ' Fill the range
    Range("A1:A10") = arrValues
    End Sub

Posting Permissions

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