+ Reply to Thread
Results 1 to 12 of 12

Sort ascending and/or descending based of headers

  1. #1
    Forum Contributor
    Join Date
    06-30-2018
    Location
    Sweden
    MS-Off Ver
    2016.
    Posts
    397

    Sort ascending and/or descending based of headers

    I want to sort headers ascending if they are sorted descending and descending if they are sorted ascending.

    At the moment I have the following code:

    Please Login or Register  to view this content.
    How can I do this?

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Sort ascending and/or descending based of headers

    Maybe:

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Forum Contributor
    Join Date
    06-30-2018
    Location
    Sweden
    MS-Off Ver
    2016.
    Posts
    397

    Re: Sort ascending and/or descending based of headers

    Thank you for your quick reply! Unfortunately the code doesn't allow me to click one time to sort ascending and then click one time again and sort descending.

  4. #4
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Sort ascending and/or descending based of headers

    to click one time to sort ascending and then click one time again and sort descending.
    Where do you want to clic, in the header ?
    - Battle without fear gives no glory - Just try

  5. #5
    Forum Contributor
    Join Date
    06-30-2018
    Location
    Sweden
    MS-Off Ver
    2016.
    Posts
    397

    Re: Sort ascending and/or descending based of headers

    Hi, thank you for your reply! You are correct, click the header one time and it sorts descending/ascending. Click again and it sortes vice versa!

  6. #6
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: Sort ascending and/or descending based of headers

    How about
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    06-30-2018
    Location
    Sweden
    MS-Off Ver
    2016.
    Posts
    397

    Re: Sort ascending and/or descending based of headers

    Thank you Fluff13, your code works flawlessly!

    Would it be possible to have 3 instances of the code running? For 3 different tables I am filtering.

  8. #8
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: Sort ascending and/or descending based of headers

    What are the ranges for each table?

  9. #9
    Forum Contributor
    Join Date
    06-30-2018
    Location
    Sweden
    MS-Off Ver
    2016.
    Posts
    397

    Re: Sort ascending and/or descending based of headers

    Table1 has range B10:O300

    Table2 has range B303:O593

    Table3 has range B596:O886

  10. #10
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: Sort ascending and/or descending based of headers

    How about
    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    06-30-2018
    Location
    Sweden
    MS-Off Ver
    2016.
    Posts
    397

    Re: Sort ascending and/or descending based of headers

    Flawless! Thank you!

    After I filter the 3 tables, ActiveSheet.ShowAllData only resets one table. Perhaps you know how to fix it?

  12. #12
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: Sort ascending and/or descending based of headers

    Glad to help & thanks for the feedback

    You'll need to loop through the tables, if you have problems with that, then you'll need to start a new thread.

+ 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] Automatically Sort Ascending to Descending...
    By Jhon Mustofa in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 12-08-2017, 10:17 AM
  2. [SOLVED] sort an array wrt two columns one ascending and the other descending
    By mehmetics in forum Excel General
    Replies: 6
    Last Post: 10-25-2014, 07:49 AM
  3. [SOLVED] Fix Sub row label instead of using Sort by Ascending or Descending
    By so_nice3 in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 08-18-2014, 02:21 AM
  4. Can you sort a chart out in Ascending/Descending Order
    By dandavis1 in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 11-26-2010, 09:52 AM
  5. sort function - from ascending to descending
    By jimmyp in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-14-2006, 02:15 PM
  6. [SOLVED] Help on autofilter sort ascending and descending!
    By crapit in forum Excel General
    Replies: 2
    Last Post: 12-12-2005, 10:45 AM
  7. [SOLVED] Sort other than by alphabetical ascending/ descending
    By Melissa in forum Excel General
    Replies: 6
    Last Post: 09-02-2005, 03: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