+ Reply to Thread
Results 1 to 8 of 8

Listbox sort/filter by date time?

  1. #1
    Registered User
    Join Date
    04-27-2020
    Location
    Riverside, California
    MS-Off Ver
    2016
    Posts
    10

    Listbox sort/filter by date time?

    I have a userform with a listbox that displays data from a worksheet. I am wanting to get that data to display in the listbox by current date and time. So when a user enters new data he/she sees the most current lines of data. This is to help the user so they don't enter duplicate information.

    I am hoping this can be accomplished programmatically because in the near future this form will be linked to a database not a worksheet.

    Here is the code to populate my listbox:

    Please Login or Register  to view this content.
    And the code to reload my listbox when the save button is clicked by calling "RefreshListbox" :
    Please Login or Register  to view this content.
    Screen Shot of the Userform:

    Capture.JPG
    Last edited by rp1xlox; 05-07-2020 at 05:12 PM. Reason: SOLVED

  2. #2
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Listbox sort/filter by date time?

    Maybe sort the data before populate the listbox ?

    kind regards
    Leo

  3. #3
    Registered User
    Join Date
    04-27-2020
    Location
    Riverside, California
    MS-Off Ver
    2016
    Posts
    10

    Re: Listbox sort/filter by date time?

    Quote Originally Posted by LeoTaxi View Post
    Maybe sort the data before populate the listbox ?

    kind regards
    Leo
    That would be fine if this werent to be linked to a database.

  4. #4
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Listbox sort/filter by date time?

    in this case i would copy the data to independed sheet, sort it there and populate listbox from there,
    faster way maybe is to create collection or array list in memorie, but for me to difficult.

    kind regards
    Leo

  5. #5
    Registered User
    Join Date
    04-27-2020
    Location
    Riverside, California
    MS-Off Ver
    2016
    Posts
    10

    Re: Listbox sort/filter by date time?

    Anyone else maybe?

  6. #6
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: Listbox sort/filter by date time?

    Why have you shown your Excel loading code for the Listbox if you are doing this directly from a database.
    Have you the link code to the database ?

  7. #7
    Registered User
    Join Date
    04-27-2020
    Location
    Riverside, California
    MS-Off Ver
    2016
    Posts
    10

    Re: Listbox sort/filter by date time?

    Quote Originally Posted by torachan View Post
    Why have you shown your Excel loading code for the Listbox if you are doing this directly from a database.
    Have you the link code to the database ?

    Not yet but will be soon.

  8. #8
    Registered User
    Join Date
    04-27-2020
    Location
    Riverside, California
    MS-Off Ver
    2016
    Posts
    10

    Re: Listbox sort/filter by date time?

    Was able to solve this with the help of a friend. This is the solution.

    MODULE CODE

    Please Login or Register  to view this content.

    USERFORM CODE

    Please Login or Register  to view this content.

+ 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] Formula/method to sort by specific time period within date+time ranges in cell
    By mikeskins84 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 02-13-2018, 01:12 PM
  2. Sort a Date field in the Pivot Table Filter
    By wsexcel in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-01-2017, 10:18 AM
  3. Advanced filter to sort date range
    By wpryan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-26-2015, 04:55 AM
  4. Filter info by date parameters and populate listbox
    By Raylou in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-31-2014, 09:31 AM
  5. [SOLVED] Displaying date and time format in Listbox
    By pezalmendra in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-02-2013, 09:26 AM
  6. [SOLVED] How to Sort or filter Date/Time data
    By TheWookie in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 03-31-2013, 07:00 AM
  7. Date Sort and Filter problem
    By reecetn in forum Excel General
    Replies: 2
    Last Post: 08-31-2010, 03:25 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