docs / articles / Excel VBA: Select Date from Calendar using Form

Excel VBA: Select Date from Calendar using Form

Eric Jul 09, 2026 2026-07-09 04:40:47

Streamlining tasks in Excel often involves automating repetitive processes, and VBA (Visual Basic for Applications) is an invaluable tool for this. One common task is selecting dates from a calendar. Let's delve into how you can create a user-friendly form with a calendar to select dates using Excel VBA.

Excel VBA USERFORMS #25 Date Picker Calendar revealed! Loop through Userforms and Controls  Example
Excel VBA USERFORMS #25 Date Picker Calendar revealed! Loop through Userforms and Controls Example

Before we dive into the code, ensure you have a good understanding of Excel VBA and the development environment. If you're new to VBA, consider familiarizing yourself with the basics first.

Free Excel Calendar Template
Free Excel Calendar Template

Creating the User Form

Our first step is to create a user form with a calendar control. This will allow users to easily select dates.

Excel VBA UserForm with Navigation Buttons 🚀 | See it in Action! #shorts
Excel VBA UserForm with Navigation Buttons 🚀 | See it in Action! #shorts

To create the form, follow these steps:

Adding a Calendar Control

How to insert dates from a Popup Calendar (date picker) in Excel – user guide | XLTools
How to insert dates from a Popup Calendar (date picker) in Excel – user guide | XLTools

1. Press ALT + F11 to open the Visual Basic for Applications (VBA) editor.

2. In the VBA editor, go to Insert > UserForm to create a new user form.

3. Right-click on the user form and select Add Watch Window. Then, choose Calendar Control from the list of controls.

an image of a calendar in microsoft office 365 with the date and time tab open
an image of a calendar in microsoft office 365 with the date and time tab open

Designing the Form

1. Resize and position the calendar control as desired.

2. Add other controls like labels, text boxes, or command buttons as needed. For instance, you might want a text box to display the selected date and a command button to close the form.

Excel VBA UserForm with Navigation Buttons | Move Between Records Easily!
Excel VBA UserForm with Navigation Buttons | Move Between Records Easily!

Programming the Form

Now that we have our form designed, let's add some VBA code to make it functional.

VBA UserForm
VBA UserForm
How to create a drop down list calendar (date picker) in Excel?
How to create a drop down list calendar (date picker) in Excel?
a calendar with the word january on it
a calendar with the word january on it
Calender in Excel ‼️ Amazing Excel trick using data validation and conditional formatting ✅ #Excel
Calender in Excel ‼️ Amazing Excel trick using data validation and conditional formatting ✅ #Excel
Use This Free Excel Date Picker to Enter Dates on Worksheet
Use This Free Excel Date Picker to Enter Dates on Worksheet
Create a Data Entry Form in Excel [NO VBA NEEDED]
Create a Data Entry Form in Excel [NO VBA NEEDED]
a calendar with the date and time for january to march 2013, including dates on each page
a calendar with the date and time for january to march 2013, including dates on each page
Create a date sequence in Excel and auto fill date series
Create a date sequence in Excel and auto fill date series
Excel Date Picker Tool - Contextures Blog
Excel Date Picker Tool - Contextures Blog
Create a Calendar in Microsoft Excel or Insert a Reference Calendar
Create a Calendar in Microsoft Excel or Insert a Reference Calendar
How to Insert a Calendar in Excel (the Simplest Way)
How to Insert a Calendar in Excel (the Simplest Way)
Free Excel Leave Tracker Template (Updated for 2026)
Free Excel Leave Tracker Template (Updated for 2026)
The Complete Guide to Excel VBA Form Control Checkboxes - wellsr.com
The Complete Guide to Excel VBA Form Control Checkboxes - wellsr.com
How to create and use Data Entry Form in Excel
How to create and use Data Entry Form in Excel
a screenshot of the vba user form
a screenshot of the vba user form
Best Make A Time Slotted Calendar On Excel Template
Best Make A Time Slotted Calendar On Excel Template
Interactive Userform in Excel VBA
Interactive Userform in Excel VBA
How to Create Excel VBA Data Entry Form With Search Function using Userform - Full Tutorial
How to Create Excel VBA Data Entry Form With Search Function using Userform - Full Tutorial

Double-click on the user form to open its code window. Here's a simple example of how you can make the calendar control interact with a text box:

Selecting a Date

1. In the user form's code window, add the following code to the Calendar1 control's Change event:

```vbnet Private Sub Calendar1_Change() TextBox1.Value = Calendar1.Value End Sub ```

2. This code updates the text box's value to the selected date whenever the user changes the selection in the calendar control.

Closing the Form

1. Add the following code to the CommandButton1 control's Click event to close the form when the user clicks the command button:

```vbnet Private Sub CommandButton1_Click() Unload Me End Sub ```

2. The Unload Me statement closes the user form.

Using the Form

To use the form, add the following code to a worksheet's module:

Showing the Form

1. Add the following code to a button's Click event or run it manually:

```vbnet Sub ShowCalendarForm() UserForm1.Show End Sub ```

2. This code shows the user form when the user clicks the button or runs the macro.

With this setup, users can easily select dates from a calendar and use them in their Excel tasks. This not only saves time but also makes the process more intuitive and user-friendly.

Remember, the key to effective VBA programming is to keep your code organized and easy to understand. Use comments liberally and follow best practices for naming conventions and modularity.

Happy automating! With a little effort and some creative coding, you can turn Excel into a powerful tool tailored to your specific needs.