musicgold
03-09-2009, 12:02 PM
Hi,
I am not able to transfer the data in a vba array to a range on the spreadsheet. Please see the following code. Could you please help me solve this problem?
The range A1:A10 contains the following numbers: 10, 20, 30, 40, 50, 60, 70, 80, 90, 100. However, the code writes ‘10’ in all the cells of the range B1:B10.
However if I replace the red line in the code with this statement: Myarray = Array (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
Then the code correctly writes 1 through 10 in the range B1:B10.
Sub Sheet_Fill_Array( )
Dim myarray As Variant
Set myarray = Range("A1:A10")
Range("B1:B10").Select
Range("B1:B10") = Application.WorksheetFunction.Transpose(myarray)
End Sub
Thanks,
MG.
I am not able to transfer the data in a vba array to a range on the spreadsheet. Please see the following code. Could you please help me solve this problem?
The range A1:A10 contains the following numbers: 10, 20, 30, 40, 50, 60, 70, 80, 90, 100. However, the code writes ‘10’ in all the cells of the range B1:B10.
However if I replace the red line in the code with this statement: Myarray = Array (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
Then the code correctly writes 1 through 10 in the range B1:B10.
Sub Sheet_Fill_Array( )
Dim myarray As Variant
Set myarray = Range("A1:A10")
Range("B1:B10").Select
Range("B1:B10") = Application.WorksheetFunction.Transpose(myarray)
End Sub
Thanks,
MG.