+ Reply to Thread
Results 1 to 3 of 3

Excel 2016 Sort routine issue - recording macro has sheet name in sort routine

  1. #1
    Forum Contributor
    Join Date
    07-20-2015
    Location
    Jacksonville, Florida
    MS-Off Ver
    Excel 2016
    Posts
    313

    Excel 2016 Sort routine issue - recording macro has sheet name in sort routine

    I have a workbook I originally started when using excel 2003 but am now using excel 2016. When I need a sort in a macro I use the 'record macro' option. In the 2016 sort the worksheet name is part of the sort, but the 2003 sort does not have the worksheet name. The 2016 sort causes an issue for me because I use the sort routine for 11 different worksheets, so will need to use IF commands to determine which worksheet I am sorting and put the appropriate worksheet name in the routine. This will work but I'd rather not have to duplicate the sort in 11 different IF's.

    Is there a way to change the code to just sort the current (active) worksheet? I've included a example sort from 2003 excel and one from 2016 excel.


    Here's a typical sort I have done using 2003:

    Please Login or Register  to view this content.
    Here's one I did using 2016:

    Please Login or Register  to view this content.
    As you can see the worksheet name (E2_TB_P2) is used in several places in the 2016 sort.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Excel 2016 Sort routine issue - recording macro has sheet name in sort routine

    If you want to sort the active sheet replace ActiveWorkbook.Worksheets(...) with ActiveSheet.
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    07-20-2015
    Location
    Jacksonville, Florida
    MS-Off Ver
    Excel 2016
    Posts
    313

    Re: Excel 2016 Sort routine issue - recording macro has sheet name in sort routine

    Norie,

    Thank you, that worked as I need it!!!

    I will mark this thread solved.

+ 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. I need a 2 column sort routine
    By cbb007 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-24-2014, 01:20 PM
  2. Help me Simplfy and Speed Sort Routine
    By Orada in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-02-2012, 05:31 PM
  3. Trouble with four key Sort Routine - Excel 2007
    By Orada in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-02-2012, 10:35 AM
  4. [SOLVED] Sort routine appears to be corrupting cell
    By pepps in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-09-2012, 12:28 AM
  5. Trying to automate a SORT routine
    By Dano in forum Excel General
    Replies: 3
    Last Post: 02-07-2008, 12:57 PM
  6. Generalising sort routine
    By lexcel in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-03-2006, 10:10 AM
  7. [SOLVED] sort and tally routine
    By alvin in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-04-2005, 09:05 AM

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