+ Reply to Thread
Results 1 to 8 of 8

Sort data using a button

  1. #1
    Registered User
    Join Date
    07-03-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    24

    Sort data using a button

    Hi gurus

    I am looking for macros to sort data in 4 columns using a command button. I have to sort data in three different ways using three different buttons-First two buttons to sort data on different criteria and the third button to unsort data.

    The columns where data needs to be sorted are column F(work type), column H (Plan expiry date- look for dates higher than TODAY(),column L(days with planner-look for 28 days or more) and column P (Status-look for rows which doesn't says the task is completed)

    The first button should look for all type of "Sch Reviews"(there are few types of sch reviews in that column and we need to capture all type) from column F, sort the dates in the descending order;oldest to newest in column H,look for sch reviews sitting with more than 28 days with planner and all sch review tasks are not completed(column P)

    The second button should look for all type of "New plans"(there are few types of New plans in that column and we need to capture all type) from column F, look for plans sitting with more than 28 days with planner(sort the days in the descending order;oldest to newest) and all New plans which are not completed(column P).

    Third button to unsort each time after a sort button is used.

    I tried looking for options from web and came across few in our forum but none of them fulfils the criteria am looking for. Spreadsheet is attached

    Requesting your help

    regards
    Attached Files Attached Files
    Last edited by malitec; 05-03-2018 at 09:00 AM.

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Sort data using a button

    Hi,
    When you sort data in Excel the entire table is sorted and you can choose the number of levels you want.
    one column ascending the other descending etc. but NOT look for values higher than or whatever.

    When you say Unsort, Excel has no way of knowing what the original sort order was (maybe column B?

    You can do this yourself by recording three or more macros.
    One for each sorting rule you want.

    Just start recording and set the sort rules,

    Then just add three buttons and assign the corresponding macro to the corresponding button
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Sort data using a button

    Is there any particular reason why you have 0 in column BE?

    And thinking about what you're asking and some code you have there, is it not that you want to hide and un hide rows based upon your criteria? Maybe sort bay also hide or show rows?

  4. #4
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Sort data using a button

    And the columns are not F, H, L and P but F, H, K and O
    You probably added a column somewhere in between H and L

  5. #5
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Sort data using a button

    Two macros
    SortButton0 sorts the table on Id (column B) I think this would be your 'non sorted' one
    SortButton1 sorts on the the four columns, nothing dates, sorts all 4 ascending

    The things with dates you'll have to explain better and attach a file with initial situation and what you want.

    But, you can play around with these two macros.

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    07-03-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Sort data using a button

    Thanks Keebellah

    I will try these and let you know. Appreciating your time spent on my request.

  7. #7
    Registered User
    Join Date
    07-03-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Sort data using a button

    Thanks Keebellah

    The macro works fantastic. Thanks a ton

  8. #8
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Sort data using a button

    You're welcome
    Happy coding

+ 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. Formula to sort columns instead of using the sort button
    By Hyflex in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-17-2016, 10:20 PM
  2. [SOLVED] Sort by Button is okey. I need sort by ToggleButton!
    By HerryMarkowitz in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-15-2015, 03:16 PM
  3. Replies: 1
    Last Post: 09-14-2014, 02:10 PM
  4. Problem !! Button to sort many data at once
    By Abo Rawad in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-20-2013, 05:13 AM
  5. Sort Button that does not sort Balance Columns
    By hasancem in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-28-2012, 10:31 AM
  6. sort button - how to sort large range in boxes
    By jw01 in forum Excel General
    Replies: 2
    Last Post: 03-06-2012, 09:35 PM
  7. Sort Button to Sort a Column?
    By widow in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-03-2006, 09:35 PM

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