Date Picker

Here's an overview...
- This calendar has a simple design, and is easy to use.
- The code displays the calendar and prompts the user to select a date.
- The user can easily navigate to the previous month or to the next month using the left and right arrows.
- The user can also go to a specific month and year by clicking on the month and year, respectively.
- The selected date can be returned to a worksheet cell or userform control (ie. label, textbox, etc).
Importing the Date Picker
- Download the zip folder xlc-date-picker-v1.0.zip.
- Extract all files from the zip folder.
- Open a new Excel workbook.
- Open the Visual Basic Editor (Alt+F11).
- Open the Project Explorer window (Ctrl+R).
- In the Project Explorer window, right-click the VBA project for your new workbook, select Import File from the context menu, and import the following files that were extracted earlier, one file at a time...
- frmCalendar.frm
- modCalendar.bas
- clsLabel.cls
- Return to Microsoft Excel (Alt+Q).
- Save the workbook.
How to Use the Date Picker
Run the ShowCalendar() procedure, which will call the frmCalendar.selectDate() function to display the calendar and prompt the user to select a date.
If a date is passed as an argument to the function, it initially displays the calendar for the specified date. Otherwise, if no date is passed, it initially displays the calendar for the current date.
Once the user makes a selection, the function returns the selected date.
Example 1
The following code displays the calendar for the current date, and returns the selected date to the worksheet, specifically cell J14...
Sub ShowCalendar()
Dim userDate As Date
userDate = frmCalendar.selectDate()
If userDate > 0 Then
Range("J14").Value = userDate
End If
End Sub
Example 2
The following code displays the calendar for the date specified in cell J14, and returns the selected date back to the same cell...
Sub ShowCalendar()
Dim userDate As Date
userDate = frmCalendar.selectDate(Range("J14").Value)
If userDate > 0 Then
Range("J14").Value = userDate
End If
End Sub
Sample Workbook: Download