Copying a Variant Array to a worksheet

J

John Keith

What is the short-hand method to copy a varaint array to a worksheet.

Given a variant array called vaData which is 10 rows x 5 columns

Range("F20:I26").Value = vaData 'Would copy the data to F20:I26

How can this be written dynamically using
Ubound(vaData) and UBound(vaData,2) in place of the cell range reference?
 
R

RB Smissaert

If the array is a 2-D 1-based array all will be the same as the range as
this Sub shows:

Sub test()

Dim arr

arr = Range(Cells(1), Cells(10, 10))

Range(Cells(LBound(arr), LBound(arr, 2)), Cells(UBound(arr), UBound(arr,
2))) = arr

End Sub


RBS
 
J

John Keith

Just answered my own question...
Addr = "$F$20"
Addr = Addr & ":" & Range(Addr).Cells(UBound(vaData), _
UBound(vaData, 2)).Address
Range(Addr).Value = vaData
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top