+ Reply to Thread
Results 1 to 7 of 7

how to re-arrange columns based on a specified order

  1. #1
    Registered User
    Join Date
    01-04-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    15

    how to re-arrange columns based on a specified order

    Hi,

    I'm having difficulty with a macro. I'm trying to re-order the columns in a tab based on a specified order. For example the top row has "x" in column A (cell a1), z in column B (cell b1), y in column C (cell c1), w in column D (cell d1). Could you please help me figure out the macro required to re-arrange the entire columns so that the order of the top row was "w,x,y,z"?

    I've attached the worksheet which shows the original state.
    Attached Files Attached Files
    Last edited by 2seas; 01-05-2012 at 10:13 AM. Reason: Solved

  2. #2
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: how to re-arrange columns based on a specified order

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    01-04-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: how to re-arrange columns based on a specified order

    thankyou very much for the reply. i guess i gave a bad example as the ordering i need isn't alphabetical. the actual column headers (which i can't share for security reasons) are made of text but need to be ordered in a particular way. so giving another example, let's say the column headers were names: James, Andy, Karen. How can I write a macro to sort the entire columns so that the names in the top row would be in the order Karen, Andy, James?

  4. #4
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: how to re-arrange columns based on a specified order

    Quote Originally Posted by 2seas View Post
    ... let's say the column headers were names: James, Andy, Karen. How can I write a macro to sort the entire columns ... in the order Karen, Andy, James?
    2seas, can you explain the principle (rule) of this sort?

  5. #5
    Registered User
    Join Date
    01-04-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: how to re-arrange columns based on a specified order

    the principle rule is to be able to sort entire columns according to a specified order of the top row. so if i specified the order for the top row (say for example in a list somewhere) the macro should work in such a way as to re-sort the columns so that at the end the top row aligns to the initial specification. does that help clear up the requirement?

  6. #6
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: how to re-arrange columns based on a specified order

    For example. Try to change the order of words in green cells (H1:H4), and click the green arrow.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    01-04-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: how to re-arrange columns based on a specified order

    this is great! thank you very much.

+ 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