The frmDatePicker userform linked to by this page remains the copyrighted material of Abbydale Systems. You are free to use the material but please honor the copyrights.

The usual disclaimers apply.

This code is based on code not developed by Abbydale Systems LLC that has been extensively modified make it a lot more flexible.

It is a very useful add-in to any spreadsheet that needs a user to input dates. To use this userform download it and then import it into your spreadsheet via the VBA developer.

This userform is not downward compatible with the previous one, meaning that you cannot simply replace the old version with this one.

Changes in this code include:
  • The ability to pass a start date to the userform.
  • Highlighted date selected.
  • Changed the display of the selected date to dd mmm yyyy format to avoid confusion with US and non US dates.
  • Support for US and non-US format dates (via a new module, DatePicker, available from here) which contains the subroutine, DatePickerDisplay.
  • The ability to specify your own header/title for the userform.
Note: Full implementation of the date picker requires 4 Public variables. These are defined in the DataPicker.bas module and are:

Name Type Description
strASLTitle String This is used as an optional caption/title for the date picker form to display.
ourDate String This contains the selected date upon return from the userform.
dt Date This is used to convert the passed string, if any, into a date format.
USFormat Boolean This is used to indicate if the date passed is in US format or not.


The only other requirement is, of course, the actual userform, frmDatePicker.

A screenshot of this form is shown to the left of this text. The actual zip file containing the userform (frmDatePicker) and DatePicker is available from:

here

Once the userform has been unzipped it can be imported into the Excel project. This is achieved from the VBA button on the "developer" ribbon.

If the "developer" ribbon option isn't displayed you will need to activate it. Instructions for how to do this can be found here. Import the DatePicker module and you should be set.

Using DatePicker.

In order to use the DatePicker module, you need to issue a Call for the DatePickerDisplay subroutine.

DatePickerDisplay has three (3) optional, positional parameters. If a parameter is not used, it should still be marked by a comma (,).

These are:
Position Type Description
1 Date This can be used to pass a start date to the userform, giving the ability to prevent those awfully tedious clicks to get to a distant prior or future date.

If omitted then the current date is used.
2 Variant This can be either True or False. This indicates whether the date is in US (mm/dd/yyyy) order or in non-US format (dd/mm/yyyy).

If omitted then True is assumed and the date treated as being in mm/dd/yyyy format.
3 Variant This allows the the passing of a title to be used as the userform caption (title).

If omitted the default of 'Date Picker' will be used.

Examples of Using DatePickerDisplay

Here are some examples of using the DatePickerDisplay subroutine.
  1. To show the date picker using the current date in US date format.

    Call DatePickerDisplay

    Notice that will provide no further parameters so the Date Picker will show the current date and have the caption "Date Picker".

  2. To show the date picker using the current date in a non-US date format.

    Call DatePickerDisplay(, False)

    Notice that the date parameter is not coded so a comma is used to indicate that only the second parameter has been passed. The user form will have the caption "Date Picker".

  3. To show the date picker using the start date of a different day than the current day in a non-US date format with the caption reading "Enter your Birthday".

    Call DatePickerDisplay("31/7/1901", False, "Enter your Birthday")

    This will result in the userform displaying the layout for July 1901 with the 31st highlighted. The userform will have the caption "Enter your Birthday".

  4. To show the date picker using the start date of a different day than the current day in a US date format with the caption reading "Enter your Birthday".

    Call DatePickerDisplay("7/31/1901", , "Enter your Birthday")

    Notice that the date format has been changed from the previous example as the date is in US format. We can also omit the second parameter as this is the default, or you could code True as the second parameter. The userform will display the layout for July 1901 with the 31st highlighted. The userform will have the caption "Enter your Birthday".



  5. All errors will return an ourDate value of "999".

    Please make sure your code checks for this value upon return.

    The returned date, ourDate, will be in the same format as the input date. Non-US format dates are returned in non-US format. US format dates are returned in US format.

    Extracting Information From the Returned Date

    Information can be retrieved from the returned date in the same way that it can be from any other date.

    For example if you want to know the day of the week forourDate simply code: WeekdayName(Weekday(ourdate))

    Support Removed Notice

    We have removed the old userform date picker from the website, however, if you still require a copy of this code please feel free to contact us via the contact form on this website.
 
 


If you need any support or assistance with any of the code on this site
or
if you would like to contact us, please click here

follow us on facebook
Follow us on Facebook

 

Number of unique visitors 217

Copyright © Abbydale Systems LLC 2015-2024

Abbydale Systems LLC Lic. 802696149. All rights reserved.

Last modified : Wednesday 17th of January 2024