+ Reply to Thread
Results 1 to 7 of 7

macro to sort worksheets based on column/row1 name

  1. #1
    Registered User
    Join Date
    01-09-2012
    Location
    here
    MS-Off Ver
    Excel 2003
    Posts
    68

    macro to sort worksheets based on column/row1 name

    I'm having trouble creating a macro to sort my worksheets based on a column/row1 header name. The name im trying to search for is NAME and then sort to a-z.

    I recorded a macro but the issue i'm haivng is the word NAME can be in any column its not always in the same column but it will always be in row 1 and i also need this to apply to multiple worksheets.


    Please Login or Register  to view this content.

  2. #2
    Valued Forum Contributor AlvaroSiza's Avatar
    Join Date
    09-19-2007
    Location
    Staffordshire
    MS-Off Ver
    2007
    Posts
    591

    Re: macro to sort worksheets based on column/row1 name

    Set a range variable equal to the found range via the .Find method and key your sort off of the variable.

    Maybe something like this:

    Please Login or Register  to view this content.
    Perhaps it was the Noid who should have avoided me...
    If you are satisfied with my solution click the small star icon on the left. Thanks
    1. Make a copy of your workbook and run the following code on your copy (just in case)
    2. With excel open, press ALT+F11 to open the Visual Basic Editor (VBE). From the "Insert" menu, select "Module".
    3. Paste the code from above into the empty white space. Close the VBE.
    4. From the developer tab, choose "Macros", select the Sub Name, and click "Run".

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: macro to sort worksheets based on column/row1 name

    Hello daillest319 ,

    If I understand this correctly then F2:F328 was the recorded range. This would mean that "NAME" was in F1, correct?

    You need to find the column "NAME" is in on each sheet as well?

    I assume each worksheet will have a different number of rows as well, yes?
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Registered User
    Join Date
    01-09-2012
    Location
    here
    MS-Off Ver
    Excel 2003
    Posts
    68

    Re: macro to sort worksheets based on column/row1 name

    Quote Originally Posted by Leith Ross View Post
    Hello daillest319 ,

    If I understand this correctly then F2:F328 was the recorded range. This would mean that "NAME" was in F1, correct?

    You need to find the column "NAME" is in on each sheet as well?

    I assume each worksheet will have a different number of rows as well, yes?

    yes NAME" was in F1 but its not always in f1 it could be in g1 or e1 etc

    i need to sort each worksheet and each sheet hase name in one of the columns and the number of rows is always different as well

  5. #5
    Registered User
    Join Date
    05-29-2012
    Location
    Portland OR
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: macro to sort worksheets based on column/row1 name

    If I understand your question, you're working on the same problem I'm working on. Here's my WIP:

    My need is to select a column from a dropdown list, then sort by that column and finally hide the data that's not important.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    01-09-2012
    Location
    here
    MS-Off Ver
    Excel 2003
    Posts
    68

    Re: macro to sort worksheets based on column/row1 name

    is there anyway to wirte a macro to do a custom sort based on the word in a cell? Its always going to be in row 1 but it won't always be in the same column.

    I need to find the word name and do a custom sort to sort the word NAME and expand to the whole sheet and sort from a-z.

    right now this is what i do...i click custom sort choose My data has headers and i select from the drop down list NAME
    Last edited by daillest319; 05-30-2012 at 09:10 AM.

  7. #7
    Registered User
    Join Date
    01-09-2012
    Location
    here
    MS-Off Ver
    Excel 2003
    Posts
    68

    Re: macro to sort worksheets based on column/row1 name

    Quote Originally Posted by AlvaroSiza View Post
    Set a range variable equal to the found range via the .Find method and key your sort off of the variable.

    Maybe something like this:

    Please Login or Register  to view this content.
    im sorry but im confused on what im suppose to do thie range

+ 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