+ Reply to Thread
Results 1 to 8 of 8

Create Macro based on Column Headings instead of Column Letter

  1. #1
    Spammer
    Join Date
    11-21-2014
    Location
    California
    MS-Off Ver
    2010
    Posts
    387

    Create Macro based on Column Headings instead of Column Letter

    Good Morning All.

    I have a simple Macro that I use to quickly reorganize the data in a file... but the problem I am having is there are times where the original file has columns in a different order.... so the Macro does not always rearrange properly.

    How do I make it so that instead of it just moving columns around, it will looking at the heading that the column has, and rearrange the data based on those headings?

    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,973

    Re: Create Macro based on Column Headings instead of Column Letter

    Try something like below.
    This uses array of stored heading order to find match in original and then add row for sort index. Deletes that row and add extra blank columns that you have.

    Please Login or Register  to view this content.
    "Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something."
    ― Robert A. Heinlein

  3. #3
    Spammer
    Join Date
    11-21-2014
    Location
    California
    MS-Off Ver
    2010
    Posts
    387

    Re: Create Macro based on Column Headings instead of Column Letter

    Wow! That is awesome!

    Thank you!!!

  4. #4
    Spammer
    Join Date
    11-21-2014
    Location
    California
    MS-Off Ver
    2010
    Posts
    387

    Re: Create Macro based on Column Headings instead of Column Letter

    Wow! That is awesome!

    Thank you!!!

    Is there an edit that can be made to the code where it does not necessarily look at the "sheet Name"? In the example I posted, it was Sheet 1... but it is not always named that....

  5. #5
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,973

    Re: Create Macro based on Column Headings instead of Column Letter

    Sure use ActiveSheet instead of sheet name

  6. #6
    Spammer
    Join Date
    11-21-2014
    Location
    California
    MS-Off Ver
    2010
    Posts
    387

    Re: Create Macro based on Column Headings instead of Column Letter

    Hello Again.

    I have tried using
    Please Login or Register  to view this content.
    and
    Please Login or Register  to view this content.
    and am getting errors on this.

    Where do i put/format the ActiveSheet name?

  7. #7
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,973

    Re: Create Macro based on Column Headings instead of Column Letter

    No no. You replace below worksheet reference
    Please Login or Register  to view this content.
    With...
    Please Login or Register  to view this content.
    You just have to make sure to run the code while you have the specific sheet active (the sheet in Excel window).

    Have a read of link.
    http://analystcave.com/excel-vba-wor...vs-worksheets/

  8. #8
    Spammer
    Join Date
    11-21-2014
    Location
    California
    MS-Off Ver
    2010
    Posts
    387

    Re: Create Macro based on Column Headings instead of Column Letter

    That is awesome! Thank you for your help!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Macro to combine duplicate Rows Based on a particular Column to separate INV Headings
    By prkhan56 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 02-28-2017, 06:38 AM
  2. macro to copy paste data based on column headings
    By kets0985 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-22-2014, 02:26 PM
  3. Create macro to copy data using column headings
    By zkhan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-31-2013, 02:01 AM
  4. Trying to create a new sheet based on column headings selected
    By davidhale87 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-11-2013, 01:47 PM
  5. How to turn off column letter headings?
    By VanS in forum Excel General
    Replies: 6
    Last Post: 03-03-2006, 12:20 PM
  6. Replies: 2
    Last Post: 11-23-2005, 02:55 PM
  7. What will cause column headings to change from letter to number?
    By Bob in Buffalo in forum Excel General
    Replies: 3
    Last Post: 08-08-2005, 03:05 PM

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