Array Element question
Assume a 1 dimensional array
Sub Arr1()
Dim myArray()
Dim num As Long
num = 5
ReDim myArray(0 To num - 1)
For i = 0 To num - 1
myArray(i) = i
Next
lastrow = 20
If UBound(myArray) - LBound(myArray) + 1 < 20 Then _
lastrow = UBound(myArray) - LBound(myArray) + 1
Range("A1:A" & lastrow).Value = Application.Transpose(myArray)
End Sub
If more than 20 values, then only the first 20 values will appear.
--
Regards,
Tom Ogilvy
"S G Booth" wrote in message
...
How can I refer to elements in an array?
Say just the 1st 20, and paste the values into
"A1" of the activesheet, please?
What if there were less than 20 elements?
Regards.
|