+ Reply to Thread
Results 1 to 7 of 7

Why DOESN'T this Sort Code work?

  1. #1
    Forum Contributor
    Join Date
    10-02-2008
    Location
    Berkeley, CA
    MS-Off Ver
    Windows 2007
    Posts
    105

    Why DOESN'T this Sort Code work?

    This Code works
    Please Login or Register  to view this content.
    and Code this doesn't work
    Please Login or Register  to view this content.
    So what am I missing here? Thanks for any help you can give me.
    Mac
    Last edited by CaptMac; 03-18-2016 at 01:09 PM. Reason: Corrected a line

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Why DOESN'T this Sort Code work?

    Hi CaptMac

    I suspect because Sheet and Name are reserved words in Excel.
    Last edited by jaslake; 03-18-2016 at 12:44 PM.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Forum Contributor
    Join Date
    10-02-2008
    Location
    Berkeley, CA
    MS-Off Ver
    Windows 2007
    Posts
    105

    Re: Why DOESN'T this Sort Code work?

    SHEET is not a reserved word. I've used it lots.
    Mac

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Why DOESN'T this Sort Code work?

    Please Login or Register  to view this content.
    Unqualified, Range refers to a range on the active worksheet, so if Worksheets("name") isn't active when the code executes, it won't work.

    The same is true of the first code.

    You are also not specifying a sort key.
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Forum Contributor
    Join Date
    10-02-2008
    Location
    Berkeley, CA
    MS-Off Ver
    Windows 2007
    Posts
    105

    Re: Why DOESN'T this Sort Code work?

    SHG,

    In fact SHEET is "ACTIVATE"ed. I changed the code to reflect that. That doesn't seem to be the problem. And I've tried it on my test code.

    Mac

  6. #6
    Forum Contributor
    Join Date
    10-02-2008
    Location
    Berkeley, CA
    MS-Off Ver
    Windows 2007
    Posts
    105

    Re: Why DOESN'T this Sort Code work?

    Here's the Answer:

    When you sort, a sort is done on each column before the print of the whole thing is done.
    And the spec for the column sort must be for only 1 column.
    So you can't do a column sort over the range "A1:J9". It has to be "A1:A9".

    Mac

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Why DOESN'T this Sort Code work?

    Please Login or Register  to view this content.
    Of course you can, just as you can from the user interface. You just need to specify the sort key.

    And if you sort col A only, you destroy its relationship to the other columns.

+ 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] Need help with VBA code. Tons of code seperated in two, second part of code doesn't work.
    By FragaGeddon in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 11-30-2015, 11:46 AM
  2. code doesn't work when i change.
    By superchew in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-14-2015, 03:11 PM
  3. [SOLVED] Code in Worksheet_Change doesn't work
    By Rufles in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-25-2014, 06:09 AM
  4. code from Excel Help doesn't work
    By ryan darrow in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-04-2011, 01:17 PM
  5. [SOLVED] why doesn't sort work when it's choosen before protecting sheet
    By Mearll in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-01-2006, 03:35 PM
  6. [SOLVED] Why doesn't ths VBA Code work?
    By Mac Lingo in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-23-2005, 10:10 PM
  7. vba code doesn't work
    By lschuh in forum Excel Programming / VBA / Macros
    Replies: 24
    Last Post: 07-22-2005, 02:05 PM

Tags for this Thread

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