Date Picker

Calendar

Here's an overview...

Importing the Date Picker

  1. Download the zip folder xlc-date-picker-v1.0.zip.
  2. Extract all files from the zip folder.
  3. Open a new Excel workbook.
  4. Open the Visual Basic Editor (Alt+F11).
  5. Open the Project Explorer window (Ctrl+R).
  6. 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
  7. Return to Microsoft Excel (Alt+Q).
  8. 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