Results 1 to 3 of 3

Paste Multidimensional Array into 1 Range Column

Threaded View

  1. #1
    Registered User
    Join Date
    08-16-2007
    Posts
    50

    Paste Multidimensional Array into 1 Range Column

    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
    Last edited by mcclanat; 05-07-2012 at 07:55 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1