+ Reply to Thread
Results 1 to 2 of 2

Move Columns Based on Header

  1. #1
    Registered User
    Join Date
    09-21-2010
    Location
    Boston, MA
    MS-Off Ver
    Excel 2003
    Posts
    81

    Move Columns Based on Header

    Hello all,

    Just need a little help writing a macro that will rearrange columns in a worksheet based on the header.

    Currently, my worksheets have up to 10 different unique column headers that need to be in a specific order (after running the macro).

    However, the worksheets may not always contain all 10 unique headers, sometimes only 6 or 8. If this is the case, the macro should simply place the columns in order (skipping over those columns missing).

    For example:

    DFACBE becomes: ABCDEF

    DFABE becomes: ABDEF

    If columns need to be placed in a specific column, maybe a separate function that will delete empty columns if needed.

    Any help would be most appreciated – thanks!

  2. #2
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Move Columns Based on Header

    Why not start by recording a macro that captures the steps of sorting the the data from left-to-right?
    Select the data > Menu > Data > Sort: options > sort left to right

    From here, it is just a matter of tweaking the code to make it more efficient.
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

+ 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