+ Reply to Thread
Results 1 to 5 of 5

Transpose an Array

  1. #1
    Registered User
    Join Date
    06-05-2012
    Location
    London, Canada
    MS-Off Ver
    Excel 2003
    Posts
    40

    Transpose an Array

    Good morning folks! Simple question that I suspect doesn't have a simple answer.

    How do I TRANSPOSE the values in an array?

    I have an array that I needed to ReDim Preserve and it was build up dynamically. I did so in a loop using a Variable for the array size which forced me to place the part of the array that contained the variable on the right of the Variable

    Example: ReDim Preserve NewData(1 To 5, 1 To k) As Variant

    When placing the data on the new sheet I want the data to be: NewData(1 To k, 1 To 5) TRANSPOSED

    Any help would be appreciated.

    ---------- Post added at 09:57 AM ---------- Previous post was at 09:49 AM ----------

    GOT IT!!! For those who may also be wondering...

    tansData = Application.WorksheetFunction.Transpose(NewData)

  2. #2
    Valued Forum Contributor smuzoen's Avatar
    Join Date
    10-28-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003/2007/2010
    Posts
    610

    Re: Transpose an Array

    I am not sure I am clear on what you EXACTLY want - you know you do not have to loop through a range of cells to create an array. For example if you have values in A1:E25 you can place that into an array with
    Please Login or Register  to view this content.
    This will create a two dimensional array with myArr(1 to 25, 1 to 5)
    Then to transpose this into A26:Y30 you would use
    Please Login or Register  to view this content.
    When you say
    NewData(1 To k, 1 To 5)
    you cannot redimension the first value of an array.
    Using the code above the values in A1:E25 will get transposed into A26:Y30.
    Is that what you mean?
    Hope this helps.
    Anthony
    Pack my box with five dozen liquor jugs
    PS: Remember to mark your questions as Solved once you are satisfied. Please rate the answer(s) by selecting the Star in the lower left next to the Triangle. It is appreciated?

  3. #3
    Valued Forum Contributor smuzoen's Avatar
    Join Date
    10-28-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003/2007/2010
    Posts
    610

    Re: Transpose an Array

    My post was duplicated - see above

  4. #4
    Valued Forum Contributor smuzoen's Avatar
    Join Date
    10-28-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003/2007/2010
    Posts
    610

    Re: Transpose an Array

    If your problem is solved, please say so clearly, and mark your thread as Solved: Click Thread Tools above your first post, select "Mark your thread as Solved". Or click the Edit button on your first post in the thread, Click Go Advanced, select [SOLVED] from the Prefix dropdown, then click Save Changes.

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Transpose an Array

    Assuming NewData is filled properly
    Please Login or Register  to view this content.

  6. #6
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Transpose an Array

    @ Aphyx

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. I'll do that for you now but please keep in mind for your future threads that Rule #9 requires you to do that yourself. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

  7. #7
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Transpose an Array

    @ Aphyx

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. I'll do that for you now but please keep in mind for your future threads that Rule #9 requires you to do that yourself. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

+ Reply to Thread

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