+ Reply to Thread
Results 1 to 16 of 16

sort data based on date for multiple cases

  1. #1
    Forum Contributor
    Join Date
    07-14-2021
    Location
    LY
    MS-Off Ver
    2019
    Posts
    271

    sort data based on date for multiple cases

    hi
    I attach some pictures for six cases inside the sheet how should show in listbox on userform . the code populates data based on column (4) in listbox. now I would make it more flexible to sort based on date for item is written in textbox1 .
    case1 when run the userform populate data in listbox
    case2 I want sort data based on select last date after write item in textbox1 based on column 4 in listbox
    case3 I want sort data based on select old date after write item in textbox1 based on column 4 in listbox
    case4 I want sort data based on select reset after write item in textbox1 based on column 4 in listbox should show whether last or old date together
    case 5 I want sort data based on select month and combobox for specific month after write item in textbox1 based on column 4 in listbox
    note: I've found I do not need optionbutton MONTH . just depends on combobox1 to select month
    case6 I want sort data based on write the date (from,to) in textbox2,3 after write item in textbox1 based on column 4 in listbox
    thanks in advance
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    07-14-2021
    Location
    LY
    MS-Off Ver
    2019
    Posts
    271
    is there any help?

  3. #3
    Forum Expert
    Join Date
    01-25-2011
    Location
    Belgium, Alveringem
    MS-Off Ver
    Excel 2003, 2007, 365
    Posts
    1,418

    Re: sort data based on date for multiple cases

    as starter, this one.
    Later I'll add the dates from to.
    Only problem now, the 1st row should be the headers, when you use optionbox1 or 2, but that's a minor detail.

    Your A10 was a string, not a real date "1/13/2021"
    Attached Files Attached Files
    Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

  4. #4
    Forum Expert
    Join Date
    01-25-2011
    Location
    Belgium, Alveringem
    MS-Off Ver
    Excel 2003, 2007, 365
    Posts
    1,418

    Re: sort data based on date for multiple cases

    newer version,
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    07-14-2021
    Location
    LY
    MS-Off Ver
    2019
    Posts
    271

    Re: sort data based on date for multiple cases

    thanks and I appreciate your trying to help me , but you seem misunderstood what I want . all of cases should happend based on write the item in textbox which depend on column(4) in listbox . by the way condition MONTH doesn't work . it shows all of the months when choose specific month .

  6. #6
    Forum Expert
    Join Date
    01-25-2011
    Location
    Belgium, Alveringem
    MS-Off Ver
    Excel 2003, 2007, 365
    Posts
    1,418

    Re: sort data based on date for multiple cases

    the month was the only thing i didn't tackle.
    Now I did.

    The dates in column 1, i modified the format to "dd mmm yyyy" to be sure that we see the same date, you can modify it again to your idea.

    I think it's oké.
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    07-14-2021
    Location
    LY
    MS-Off Ver
    2019
    Posts
    271

    Re: sort data based on date for multiple cases

    I think it's oké.
    unfortunately not absolutely . as I said
    should happend based on write the item in textbox which depend on column(4) in listbox
    I appreciate your trying for help me

  8. #8
    Forum Expert
    Join Date
    01-25-2011
    Location
    Belgium, Alveringem
    MS-Off Ver
    Excel 2003, 2007, 365
    Posts
    1,418

    Re: sort data based on date for multiple cases

    there is already so much done by so many different people with different mindsets in this UF, it's a spaghetti now.
    Your VBA-skills are basic, I suppose, because you only can say it's absolutely not oké without further explanation.
    I also checked previous questions in this site.
    So, I quit.

  9. #9
    Forum Expert
    Join Date
    01-25-2011
    Location
    Belgium, Alveringem
    MS-Off Ver
    Excel 2003, 2007, 365
    Posts
    1,418

    Re: sort data based on date for multiple cases

    Edit : I couldn't edit my previous post, so this is to be added.
    Better than this ???
    Attached Files Attached Files

  10. #10
    Forum Contributor
    Join Date
    07-14-2021
    Location
    LY
    MS-Off Ver
    2019
    Posts
    271

    Re: sort data based on date for multiple cases

    honestly . this is very fantastic ! but it seems the month should also fix it . when write the item in textbox1 and select MONTH from option button and select specific month from combobox doesn't work . it only works when the textbox1 is empty . may you fix it please?

  11. #11
    Forum Expert
    Join Date
    01-25-2011
    Location
    Belgium, Alveringem
    MS-Off Ver
    Excel 2003, 2007, 365
    Posts
    1,418

    Re: sort data based on date for multiple cases

    with less options (optionbutton4), it's less complex.
    Attached Files Attached Files

  12. #12
    Forum Contributor
    Join Date
    07-14-2021
    Location
    LY
    MS-Off Ver
    2019
    Posts
    271

    Re: sort data based on date for multiple cases

    great ! just I have a littile problem . when write the date in textbox2,3 if there is any optionbutton is selected this condition doesn't work . it should be unselected to work with this case (dates in textbox2,3) . to do that I have to close the userform and open again to overcome this problem , but I believe to be possible automatically by code .
    thanks again

  13. #13
    Forum Expert
    Join Date
    01-25-2011
    Location
    Belgium, Alveringem
    MS-Off Ver
    Excel 2003, 2007, 365
    Posts
    1,418

    Re: sort data based on date for multiple cases

    matter of interpretation !!!
    when textbox2-3 have dates and there are several rows (for example 3) of data present, then choosing the 1st or 2nd optionbutton selects the oldest or youngest of those (3) actual rows, not of all the rows.
    If you want the oldest or most recent of all, empty (manually) the one or both textboxes2-3.

  14. #14
    Forum Contributor
    Join Date
    07-14-2021
    Location
    LY
    MS-Off Ver
    2019
    Posts
    271

    Re: sort data based on date for multiple cases

    what I'm talking about if I have ever selected any optionbutton and when move to next condition just search between two dates in textbox2,3 after write in textbox1 .this condtion doesn't work at all becuase I have one of optionbutton is selected. to work I have to unselect the optionbutton . and this happens when close the userform and run again then all optionbutton are unselected and the condition work. so if there is way to do that by the code automatically when fill texbox2,3 together ,then should all optionbuttons are unselected .

  15. #15
    Forum Expert
    Join Date
    01-25-2011
    Location
    Belgium, Alveringem
    MS-Off Ver
    Excel 2003, 2007, 365
    Posts
    1,418

    Re: sort data based on date for multiple cases

    option 1 = last
    option 2 = first
    option 3 = reset (=not option1 & not option2)
    so if you want to undo option1 (=last), select option3 (=reset), without closing the UF.

    What was the purpose of "reset" otherwise ?

    While initializing the UF, perhaps already automatically selecting option3, to avoid confusion ?
    add a last line in "userform_Initialize"
    Please Login or Register  to view this content.
    Last edited by bsalv; 11-27-2021 at 10:32 AM.

  16. #16
    Forum Contributor
    Join Date
    07-14-2021
    Location
    LY
    MS-Off Ver
    2019
    Posts
    271

    Re: sort data based on date for multiple cases

    my apologies ! every thing is ok . I don't press the enter after fill the date in textbox 2,3. I thought to doesn't work. but I note if I repeate the last date more than time it will show the last date and ignore the others repeated dates for the last date. and the same thing with old date
    thanks so much for your time and patience !
    Last edited by Mussa-A; 11-29-2021 at 09:36 AM.

+ 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. Sort Data based on Date
    By ramepetla in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-14-2017, 03:23 PM
  2. To Automatically Sort data based on date
    By divi123 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 05-20-2014, 01:43 AM
  3. Sort Data based on Multiple InputBox
    By Kwame001 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-04-2013, 03:31 PM
  4. Split data into multiple sheets - dispatching cases
    By badaza in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-20-2012, 11:22 AM
  5. Sort data based on date
    By viuf81 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-06-2011, 07:24 AM
  6. sort data based on date and time priority
    By stoey in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-19-2010, 02:55 PM
  7. Sort,Count & Sum data based on unique date
    By excelkeechak in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-26-2009, 06:57 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