+ Reply to Thread
Results 1 to 6 of 6

selecting range for custom sort

  1. #1
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,176

    selecting range for custom sort

    I am trying to sort a range of values using private sub worksheet before double click. The following code works fine if I want to sort entire columns
    Please Login or Register  to view this content.

    However, I only want to sort A2:M44 as row 45 has totals. I tried to modify code as follows but keep receiving run time error. Any assistance appreciated.
    Please Login or Register  to view this content.
    Last edited by maacmaac; 09-26-2010 at 08:25 PM.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,064

    Re: selecting range for custom sort

    If you double-click a cell that isn't in A1:M1, then SortColumn has no value.
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,176

    Re: selecting range for custom sort

    Not quite what I was looking for. I have modified my example and attached a sample. If you open the sample, you will see I have a table (A1:D10). If I double click on any of the column headers, A1-D1, I want the table to sort on the column that is double clicked. However, in this example I only want to the data that is in A2:D9 sorted. The way the code is now, is it also sorts the data in row 10, which is the summary data. Thanks again for any comments.
    Attached Files Attached Files

  4. #4
    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: selecting range for custom sort

    Hello maacmaac,

    I changed the range to "A2:D9" and it works fine for me.
    Please Login or Register  to view this content.
    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!)

  5. #5
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,176

    Re: selecting range for custom sort

    Now it is working. Thanks. I don't know why it wasn't working before.

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,064

    Re: selecting range for custom sort

    I think you missed my point. If you double click a cell that is not the header row, your code still tries to sort, but sortcolumn has no value, so you should get an error.

+ 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