Hello,
I am trying to create a macro that will take a multidimensional array and paste each column of the array into one column of a worksheet. I figured out how to create the array, and I can paste the array into a range with same dimensions. I have been looking for a way to paste one column at a time below each other to get the entire content of the array into one column. Does anyone know how to paste one entire column of a multidimensional array into a range? Or, does anyone have a better way of accomplishing the concept? Below is the test code I have been using. Any help would be appreciated.
thank you
Sub ArrayTest()
Dim NumOfColumns As Integer, NumOfRows As Integer
Dim TestArray() As String
NumOfColumns = 3
NumOfRows = 3
ReDim Preserve TestArray(NumOfRows, NumOfColumns - 1) As String
TestArray(0, 0) = "A"
TestArray(0, 1) = "B"
TestArray(0, 2) = "C"
TestArray(1, 0) = "1"
TestArray(2, 0) = "2"
TestArray(3, 0) = "3"
TestArray(1, 1) = "1"
TestArray(1, 2) = "1"
'This doesn't work, but I would like something equivalent to:
'Range("d1:d4").Value = TestArray.Column(1)
'Range("d5:d6").Value = TestArray.Column(2)
'Range("d7:d8").Value = TestArray.Column(3)
End Sub
Bookmarks