+ Reply to Thread
Results 1 to 5 of 5

Excel VBA to Set Combobox Date to initialize (default) to today's date

  1. #1
    Registered User
    Join Date
    08-13-2012
    Location
    Adelaide, South Australia
    MS-Off Ver
    Excel 2010
    Posts
    36

    Excel VBA to Set Combobox Date to initialize (default) to today's date

    I have a Combobox (Name: StartDate) containing a list of date values to select from.

    The ListFillRange sources a list of dates including today's date (Now) with approximately 80 retrospective date values as well as a number of future dates.

    When the user clicks on the StartDate combobox I would like the date value to default to "today's" date but still be able to select an alternative retrospective or prospective date from the available list.

    See attached sheet for reference.

    Can someone please assist with the appropriate VBA code?

    Thanks

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Excel VBA to Set Combobox Date to initialize (default) to today's date

    This is sort of quick and dirty. The cell that is linked to the combo box is H3. I3 has a match command to find on what row today's date is. This short bit of VB code can either be on a sheet activate event or attached to a button or both.
    Please Login or Register  to view this content.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Registered User
    Join Date
    08-13-2012
    Location
    Adelaide, South Australia
    MS-Off Ver
    Excel 2010
    Posts
    36

    Re: Excel VBA to Set Combobox Date to initialize (default) to today's date

    Thanks dflak,

    I've applied your code. It does default the pick list date to today's date, however, once defaulted to today's date, it does not allow for the selection of another date from the list of dates.

    I would like the user to be able to either use the today's date or to change the date to any other date on the list.

    Do you know of any other code that would once the today's date has been set for the user to subsequently choose other dates from the list?

    Kind regards

  4. #4
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Excel VBA to Set Combobox Date to initialize (default) to today's date

    Hmm, interesting. It's doing the same thing to me today. I did not have that issue when I tested it before posting it.

  5. #5
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Excel VBA to Set Combobox Date to initialize (default) to today's date

    I see the problem, I had linked the SetToday macro to the combo box. I should not have done that.

    This version has the SetToday macro linked to an open workbook event and a sheet activation event. You can remove either one of these or both and/or assign the macro to a button.
    Last edited by dflak; 02-03-2017 at 10:37 AM. Reason: Add attachment

+ 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] Multiple DTpicker's to display default date as today?
    By chrismccarthy17 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-26-2016, 01:34 PM
  2. Replies: 5
    Last Post: 12-01-2015, 02:36 PM
  3. [SOLVED] Formula to compare date (including month and year) from a listed date to today's date
    By mhewitson15 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-11-2014, 05:31 PM
  4. Userform: Calender to open with today's date as default
    By Ashali in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-11-2012, 07:01 AM
  5. Making MonthView default to today's date or leave blank
    By raehippychick in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-21-2008, 11:30 AM
  6. Default today's date - Excel 2000
    By Abay in forum Excel General
    Replies: 4
    Last Post: 08-25-2005, 12:05 AM
  7. Excel Default date for date format
    By smurphy123 in forum Excel General
    Replies: 11
    Last Post: 01-24-2005, 12:06 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