Excel’s VBA InputBox does not include a calendar or date-picker control: it asks the user to type a response. For Microsoft 365 on Windows, use Application.InputBox with VBA validation for a straightforward date prompt, or build a UserForm if users need to choose a date from a calendar.
Why the VBA InputBox has no calendar
The standard VBA InputBox function is a simple dialog for entering text. It has a prompt, a title, and a text field, but no option that changes that field into a calendar. Excel for Microsoft 365 on Windows does not provide a general built-in VBA setting that adds a pop-up date picker to this dialog.
This distinction matters because “date picker” can describe two different things: a control that displays a calendar for selecting a date, or a text box that accepts a date and checks whether it is valid. An InputBox can do the second when paired with VBA; it cannot do the first on its own. A date typed into a prompt can still be converted to a genuine Excel date value, which is stored as a number and displayed using a date format.
For occasional entry, a clear prompt and input validation may be enough. For a workflow where users choose dates repeatedly, a calendar-based UserForm can reduce typing and ambiguity. The appropriate choice depends on how important convenient selection is compared with simplicity, compatibility, and maintenance.
InputBox and Application.InputBox are different
VBA provides both the InputBox function and Excel’s Application.InputBox method. They look similar to users, but the latter offers a Type argument that restricts the kind of response. For example, Type:=1 requests a number, Type:=2 requests text, and Type:=8 lets the user select a range. None of these types means “show a date calendar.”
Dates create a subtle issue: Excel dates are numeric serial values, but a number-only prompt is not necessarily an intuitive way to request a date. A person may enter a familiar date string, while Excel interprets it according to regional date settings. For that reason, a text prompt followed by explicit validation is usually clearer than asking users to enter a date serial number.
Cancellation is also handled differently. The VBA InputBox function returns an empty string when the user cancels, which is indistinguishable from submitting an empty response. Application.InputBox returns Boolean False on Cancel. If you use the latter, store the result in a Variant so the code can detect that Boolean return before treating the result as text.
A simple prompt with date validation
This example accepts a date using the computer’s regional date conventions, checks the response with IsDate, converts it to a VBA Date, and writes it to cell A1 on a worksheet named Sheet1. Change the sheet name or destination cell to suit the workbook.
Sub AskForDate()
Dim answer As Variant
Dim dateText As String
Dim enteredDate As Date
Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets("Sheet1")
answer = Application.InputBox( _
Prompt:="Enter a date, such as 11/2/2026:", _
Title:="Date entry", Type:=2)
' Application.InputBox returns Boolean False when canceled.
If VarType(answer) = vbBoolean Then Exit Sub
dateText = Trim$(CStr(answer))
If Len(dateText) = 0 Then
MsgBox "Enter a date before continuing.", vbExclamation
Exit Sub
End If
If Not IsDate(dateText) Then
MsgBox "That entry is not recognized as a date.", vbExclamation
Exit Sub
End If
enteredDate = CDate(dateText)
ws.Range("A1").Value = enteredDate
ws.Range("A1").NumberFormat = "yyyy-mm-dd"
End Sub
In the example, IsDate checks whether VBA recognizes the text as a date in the current environment, and CDate converts it. Formatting the result as yyyy-mm-dd makes the displayed value consistent, but it does not change how the original text was interpreted. For instance, 04/05/2026 can mean April 5 or May 4 depending on regional settings. A consistent display format cannot remove that ambiguity after entry.
To add this macro in desktop Excel for Windows, press Alt+F11 to open the Visual Basic Editor, choose Insert > Module, and paste the code into the module. On a Mac, Option+F11 (sometimes with the Fn key) opens the editor on many keyboards; menu availability and shortcuts can vary by keyboard setup. Save the workbook as an Excel Macro-Enabled Workbook (.xlsm). Make a copy before running a macro: VBA changes cannot be undone with Ctrl+Z. Excel for the web does not run VBA macros.
Use an unambiguous date format when needed
If entries will be shared across computers with different regional settings, asking users to type an agreed format such as yyyy-mm-dd is safer than relying on slash-separated dates. The following alternative parses that format as year, month, and day, then checks that the requested calendar date really exists. It replaces the earlier macro, rather than being added inside it.
Sub AskForISODate()
Dim answer As Variant
Dim dateText As String
Dim parts As Variant
Dim yearNumber As Long
Dim monthNumber As Long
Dim dayNumber As Long
Dim candidate As Date
Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets("Sheet1")
answer = Application.InputBox( _
Prompt:="Enter a date in yyyy-mm-dd format:", _
Title:="Date entry", Type:=2)
' Cancel returns a Boolean False.
If VarType(answer) = vbBoolean Then Exit Sub
dateText = Trim$(CStr(answer))
parts = Split(dateText, "-")
If UBound(parts) <> 2 Then GoTo InvalidDate
If Not IsNumeric(parts(0)) Or Not IsNumeric(parts(1)) _
Or Not IsNumeric(parts(2)) Then GoTo InvalidDate
If CDbl(parts(0)) <> Fix(CDbl(parts(0))) _
Or CDbl(parts(1)) <> Fix(CDbl(parts(1))) _
Or CDbl(parts(2)) <> Fix(CDbl(parts(2))) Then GoTo InvalidDate
yearNumber = CLng(parts(0))
monthNumber = CLng(parts(1))
dayNumber = CLng(parts(2))
If yearNumber < 1000 Or yearNumber > 9999 _
Or monthNumber < 1 Or monthNumber > 12 _
Or dayNumber < 1 Or dayNumber > 31 Then GoTo InvalidDate
candidate = DateSerial(yearNumber, monthNumber, dayNumber)
If Year(candidate) <> yearNumber _
Or Month(candidate) <> monthNumber _
Or Day(candidate) <> dayNumber Then GoTo InvalidDate
ws.Range("A1").Value = candidate
ws.Range("A1").NumberFormat = "yyyy-mm-dd"
Exit Sub
InvalidDate:
MsgBox "Enter a real date in yyyy-mm-dd format, for example 2026-11-02.", _
vbExclamation
End Sub
The component comparison is important because VBA’s DateSerial normalizes out-of-range days. Without that check, a value such as a day beyond the end of a month could roll into the next month instead of being rejected. The code also rejects decimal components and years outside its chosen range. If a project needs dates before 1000, adjust the year rule deliberately rather than accepting unintended inputs.
When a calendar UserForm makes sense
A VBA UserForm gives you a window in which to place labels, buttons, text boxes, and other controls. It is the practical route when a user needs a visible calendar rather than a typed response. A custom calendar can be drawn using standard form controls and VBA code, or a calendar control can be used where the target Excel installation supports it.
A custom form offers control over layout and behavior: you can add Next and Previous month buttons, prevent selection outside an allowed date range, and return the chosen date to a cell or calling procedure. The trade-off is development and upkeep. The code must handle month lengths, leap years, navigation, cancel actions, and the selected value. It also needs to be tested with the workbook’s intended Excel versions and regional settings.
A calendar UserForm is most useful when date selection is frequent, users are uncomfortable typing dates, or the workflow needs rules such as “only dates in the current month.” For a one-off prompt, a validated text entry is often easier to understand and maintain. A worksheet cell with a clear instruction may be simpler still.
Legacy date-picker controls and compatibility
Some online instructions recommend adding the Microsoft Date and Time Picker control, often associated with the older MSCOMCT2.OCX component, to a VBA form. That advice is not a dependable general solution for current Office installations. The control may be missing, may depend on legacy components or matching Office bitness, and is not a cross-platform choice. ActiveX controls are not supported in Excel for Mac, and Excel for the web does not run VBA forms.
Before choosing any external or legacy control, check the exact Office version, whether it is 32-bit or 64-bit, and every computer on which the workbook must run. A form that opens on its creator’s PC may fail for another user if that user does not have the same control installed and available. For a workbook shared widely, a custom form built from supported VBA elements or a non-macro alternative is generally easier to distribute than an obscure dependency.
Choosing the right date-entry method
- Use an InputBox with validation when users enter dates occasionally and a typed value is acceptable. Specify the expected format and reject invalid input.
- Use a UserForm calendar when selecting visually is a real usability requirement and you can support the VBA code across the target desktop versions.
- Use worksheet cells when people are entering several dates in a table. Data > Data Validation can restrict entries to dates and set a permitted range, although it does not turn the cell into a calendar picker.
- Use a non-VBA process when the workbook must work in Excel for the web or on devices where macros are disabled. A web form or another approved data-entry tool may be more suitable.
Whatever method you choose, decide what should happen when the user cancels, leaves the entry blank, supplies an invalid date, or chooses a date outside the allowed range. Those cases are part of the interface, not unusual exceptions. Clear messages and predictable behavior prevent a date prompt from silently writing the wrong value.
Common problems and how to avoid them
The prompt accepts a date but the cell shows a number. Excel stores dates as serial numbers. Apply a date number format to the destination cell; the underlying value can still be used for sorting and date calculations.
Dates switch day and month. This usually reflects regional interpretation of ambiguous text, not a faulty cell format. Ask for an unambiguous year-month-day input and parse its components, or make the expected local format explicit.
Cancel is treated as an invalid date. With Application.InputBox, check whether the returned Variant is Boolean before converting it to text. With the VBA InputBox function, cancellation returns an empty string, so decide whether blank and Cancel can share the same behavior.
The macro is missing or blocked. Confirm the workbook is saved as .xlsm, and check the organization’s macro security policy. Do not ask users to enable macros from untrusted files. A workbook opened in Excel for the web cannot execute its VBA code, even if the macro is present in the file.
A calendar control works for one person but not another. The workbook may depend on a legacy control not installed on the second computer, or on a platform that does not support it. Test on the actual target installations before distributing the file.
Frequently Asked Questions
Can I make the VBA InputBox show a calendar?
No. Neither the standard VBA InputBox nor Application.InputBox has a built-in calendar display option. Use a UserForm calendar or another date-entry method if users must pick from a visual calendar.
Does Excel for Microsoft 365 have a built-in VBA date picker?
Excel desktop does not provide a universal built-in VBA date-picker control for this purpose. A particular workbook or add-in may provide one, but that is a separate feature with its own compatibility requirements.
Can I use a date picker in Excel for the web?
Excel for the web does not run VBA macros or VBA UserForms. Use a workflow that works in the browser, such as entering dates in worksheet cells, or collect the dates through a separate compatible tool.
How do I stop users entering an invalid date?
Read the response as text, validate it, and only write a value after it passes the checks. For consistent interpretation across regions, require a format such as yyyy-mm-dd and verify the year, month, and day rather than relying only on regional date parsing.
Will data validation add a pop-up calendar to a cell?
No. Excel’s date validation can restrict which dates are allowed and display an input message or error alert, but it does not itself provide a calendar picker in the cell.
Related
- Excel Regression Line: Add, Format, and Interpret It
- Excel PivotChart: How to Hide Series and Keep Data
- Excel Paste Text Without Text to Columns?
Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.
More in VBA & macros
- Excel VBA Range of Object Failed? Common Causes and FixesThe Excel VBA error “Method ‘Range’ of object ‘_Worksheet’ failed” usually means VBA could not resolve the address…
- Excel VBA: Delete Rows Based on a Cell Value MatchTo delete worksheet rows when a cell matches a value, loop upward from the last used row and…
- Add Comments in Excel VBA: Notes and Threaded CommentsTo add a cell note with Excel VBA, select the cell and run ActiveCell.AddComment "Check this value." in…
- Excel Macro to Send Email: Setup, Code, and SafetyYes. In Excel for Microsoft 365 on Windows, a VBA macro can create an email in classic Outlook…
- VBA Loop Without Do: Choosing For, While, or For EachYes. In VBA, you can loop without using Do: use For...Next for a known number of repetitions, For…
- Excel VBA: Save a Worksheet as a New File SafelyTo save one Excel worksheet as a separate file with VBA, copy it to a new workbook with…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.