No: VBA’s built-in InputBox does not include a drop-down list, and Application.InputBox does not add one. To let someone choose from fixed options, create a VBA UserForm with a ComboBox set to drop-down-list mode; for a quick worksheet-based alternative, use a cell with Data Validation.
Why the built-in InputBox has no drop-down
The VBA InputBox function displays a small dialog with a prompt, a text field, and OK and Cancel buttons. It is designed to collect typed text, not to display a custom set of controls. Application.InputBox is an Excel-specific alternative that can constrain the kind of response—for example, a number or a cell reference—but it still does not provide a ComboBox or selectable list.
This distinction matters because putting a list of choices in the prompt does not make the choices selectable. You could ask a user to type “Red,” “Blue,” or “Green,” but that leaves room for spelling differences, extra spaces, and invalid answers. If the response must be one of a known set, use a control that enforces that choice or validate the text after the user enters it.
Best option: a UserForm ComboBox
A UserForm is a custom VBA dialog. Add a ComboBox to it, load the available options, and set the ComboBox’s Style to fmStyleDropDownList. That style lets a user select an item but not type an arbitrary value into the field. Add command buttons if you want clear OK and Cancel actions.
This is the closest match to an “InputBox with a drop-down.” It takes more setup than a one-line InputBox call, but it gives you control over the list, validation, labels, layout, and what happens when the user cancels.
Create the form in Excel for Windows
- Save a copy of the workbook as an Excel Macro-Enabled Workbook (
.xlsm) before adding or running VBA. Macros cannot be undone with Ctrl+Z. - Open the Visual Basic Editor with Alt+F11. On a Mac, the shortcut differs by keyboard and Excel settings; use the Visual Basic Editor command from Excel’s Developer tab or Tools menu if the shortcut is unavailable.
- In the editor, choose Insert > UserForm. In the Properties window, set the form’s
(Name)tofrmChoice. - Add a ComboBox and set its
(Name)tocboChoice. Add two CommandButtons namedcmdOKandcmdCancel; set their captions to OK and Cancel. - Double-click the form and add the form code below. Then choose Insert > Module and add the calling procedure in the next code block.
The form code loads three example options when the form opens. Replace those entries with the choices your workbook needs. The initial selection is the first item; the OK button returns the selected value, while Cancel closes the form without accepting a choice.
Option Explicit
Public WasCancelled As Boolean
Public ChosenValue As String
Private Sub UserForm_Initialize()
WasCancelled = True
With Me.cboChoice
.Style = fmStyleDropDownList
.Clear
.AddItem "Red"
.AddItem "Blue"
.AddItem "Green"
.ListIndex = 0
End With
End Sub
Private Sub cmdOK_Click()
If Me.cboChoice.ListIndex < 0 Then
MsgBox "Select an item before clicking OK.", vbExclamation
Exit Sub
End If
ChosenValue = CStr(Me.cboChoice.Value)
WasCancelled = False
Me.Hide
End Sub
Private Sub cmdCancel_Click()
WasCancelled = True
Me.Hide
End Sub
In the standard module, use this procedure to display the form and handle either outcome:
Option Explicit
Public Sub ChooseFromList()
Dim picker As frmChoice
Set picker = New frmChoice
picker.Show vbModal
If picker.WasCancelled Then
MsgBox "No choice was made.", vbInformation
Else
MsgBox "You selected: " & picker.ChosenValue, vbInformation
End If
Unload picker
Set picker = Nothing
End Sub
Run ChooseFromList from the Visual Basic Editor, or assign it to a worksheet button. Because the form is shown modally, Excel waits for the user to dismiss it before continuing the procedure. In the example, the result is displayed in a message box; in a real workbook, you could instead store it in a cell or pass it to another procedure.
How to populate and use the list
For a short, fixed list, individual AddItem lines are easy to understand. For a list maintained in the workbook, it is usually better to read values from a worksheet range when the form opens. For example, a range on a dedicated “Lists” sheet can be the single place where an administrator updates permitted departments or product categories. Keep the list source separate from the form code so that changing an option does not require editing the macro.
Before loading a range, decide how blank cells and duplicate values should be handled. A simple loop can skip blank entries, while a larger or changing list may need additional checks. Also consider what should happen if the source range is empty: show a useful message and disable OK, rather than presenting a blank form that appears broken.
If a choice drives later code, use the selected value deliberately. For instance, compare it with known values using Select Case, or write it to a clearly identified cell. Avoid assuming the user selected the first item unless that default is genuinely appropriate; a preselected option can be accepted accidentally.
Worksheet drop-down as a simpler alternative
If the user can make a choice directly on the worksheet, a Data Validation list may be simpler than a UserForm. Select the target cell in Excel for Microsoft 365 on Windows, then choose Data > Data Validation. In the dialog, set Allow to List and provide a source, such as a range containing the permitted values. The cell then displays a selection arrow when active.
A worksheet drop-down is useful when the choice belongs in a visible record, such as a status column, and users do not need a separate dialog. It can also be used with VBA: a macro can read the selected cell after the user makes a choice. A UserForm is a better fit when you need a guided interaction, several prompts at once, conditional controls, or a dialog that works without selecting a worksheet cell.
Data Validation is not a security boundary. Pasting data into cells or changing the workbook can bypass ordinary validation behavior, so macros that rely on a value should check that value before acting. Excel for the web can use many workbook features but cannot run VBA macros; users need desktop Excel to run this VBA workflow. Excel for Mac has VBA support, but form-control behavior and interface details can differ, so test the workbook on the Mac versions your audience uses.
InputBox, UserForm, or worksheet validation?
- Use
InputBoxwhen any typed response is acceptable, or when you are collecting a simple text value and will validate it separately. - Use
Application.InputBoxwhen Excel’s input-type options, such as a number or range reference, suit the task. It does not turn a list into a drop-down. - Use a UserForm ComboBox when the user must choose from a controlled list in a dialog, or when you need custom prompts and buttons.
- Use Data Validation when the choice should be made and stored in a worksheet cell, without building a custom dialog.
For a tiny list, developers sometimes ask for a workaround that puts numbered options in an InputBox prompt and asks the user to type a number. That can be adequate for a quick internal macro, but it is not a drop-down: the code must reject non-numbers and numbers outside the valid range, and users may still enter confusing responses. A ComboBox is clearer when selection accuracy matters.
Common problems and fixes
- “Variable not defined” or “method or data member not found”: Check the control and form names in the Properties window. The example expects
frmChoice,cboChoice,cmdOK, andcmdCancel. - The list accepts typing: Confirm the ComboBox’s
StyleisfmStyleDropDownList. A normal drop-down style permits typing. - The form opens but the list is empty: Confirm the initialization event is named
UserForm_Initializeand that the code is in the form’s code module, not a standard module. - Cancel still produces a result: Keep a separate cancellation flag, as in
WasCancelled. A blank selected value alone is not always a reliable way to distinguish canceling from choosing an empty item. - The macro will not run: Confirm the file is saved as
.xlsm, macros are permitted by the organization’s security settings, and the workbook is opened in desktop Excel rather than Excel for the web.
Frequently Asked Questions
Can I add a drop-down to VBA’s InputBox?
No. The built-in VBA InputBox and Excel’s Application.InputBox do not offer a drop-down control. Use a UserForm ComboBox or a worksheet Data Validation list instead.
How do I stop users typing into a VBA ComboBox?
Set the ComboBox’s Style property to fmStyleDropDownList. Users can select an item from the list but cannot enter a different value in the field.
Can I fill a UserForm drop-down from worksheet cells?
Yes. Load the ComboBox from a range during the form’s initialization, or set its row source to a suitable range. Decide how to handle blanks and missing source data so an empty list does not lead to an invalid selection.
Can a UserForm drop-down run in Excel for the web?
No. Excel for the web does not run VBA macros. The workbook and macro need to be opened in a desktop version of Excel.
Is a worksheet drop-down the same as a VBA ComboBox?
No. A Data Validation list restricts or guides an entry in a worksheet cell. A UserForm ComboBox is a control in a VBA dialog and returns a value to code; choose based on where and how the user should make the selection.
Related
- Can You Open a Corrupted Excel File Online for Free?
- OneDrive Excel File Corrupted? Practical Repair Steps
- Excel Shortcut Keys: Essential Windows and Mac Keys
Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.
More in VBA & macros
- Access VBA Error Handling: Trapping and Fixing ErrorsAccess VBA error handling lets a procedure respond when a runtime error occurs instead of stopping unexpectedly. Use…
- Excel VBA: Filter a PivotTable by Field or ValueYes. In Excel VBA, filter a PivotTable by setting a report-filter field’s CurrentPage, applying a label or value…
- Excel VBA: Insert a Row and Shift Cells DownTo insert a worksheet row in Excel VBA and push the existing rows down, use Rows(rowNumber).Insert Shift:=xlShiftDown on…
- VBA Loops Within Loops: How Nested Loops Work in ExcelYes. VBA can run one loop inside another; this is called a nested loop. The outer loop runs…
- Excel VBA Delete Whole Row: Safe Methods and ExamplesTo delete an entire worksheet row with VBA, use Rows(row_number).Delete, such as Rows(5).Delete for row 5. In a…
- Excel VBA: How to Find the Next Empty Cell in a ColumnTo find the next empty cell below the last entry in an Excel column, use VBA’s End(xlUp) navigation…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.