+ Reply to Thread
Results 1 to 4 of 4

Arrange values in columns

  1. #1
    Registered User
    Join Date
    06-22-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    9

    Arrange values in columns

    I need some help to create a macro that will arrange multiple values in columns for all available rows such that they form a matrix.
    I have attached an example of the before and after macro results.
    The number of columns and rows may vary.

    Any help would be much appreciated.

    wk
    Attached Files Attached Files

  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: Arrange values in columns

    Why is there a gap in column E where I assume a 4 would go however there is no gap between Column I with the value 9 and Column J with the value 11. Same for P having 17 and Q having 20? Is that a mistake otherwise I do not understand the logic. If it is a mistake then you could use
    Please Login or Register  to view this content.
    You will need to have a sheet named After
    Last edited by smuzoen; 07-03-2012 at 12:22 AM.
    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
    Registered User
    Join Date
    06-22-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Arrange values in columns

    Thanks for your help! Your method to arrange works for me as well.
    However, there are some situations where the macro doesn't work when the numbers change (Runtime error '13', Type mismatch).
    I have attached Example2.xlsx as one situation where it doesn't work.
    Appreciate your help to solve this.
    Attached Files Attached Files

  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: Arrange values in columns

    The reason this did not work with the number set was due to the fact I had not allowed for the situation where there is only one number in the row. In this case there was no array hence the error. Will the situation ever arise that there will be no numbers in a row? Use
    Please Login or Register  to view this content.
    This will erase the numbers in the after sheet prior to re-arranging the values.

+ 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