An Excel UserForm combo box is a VBA control that lets someone choose an item from a drop-down list, and in some configurations type a value as well. In desktop Excel for Windows, add one from the Visual Basic Editor’s Toolbox, fill its list with VBA or worksheet data, then read the selection from its Value property.
What a UserForm combo box does
A combo box puts a list of choices inside a VBA UserForm, a custom dialog window for collecting or displaying information. It is useful when an entry should come from a known set of values, such as a department, product, region, or status. The list reduces inconsistent spellings and makes data entry more controlled than asking someone to type every answer.
A combo box is different from a worksheet drop-down. A worksheet Data Validation list appears in a cell, while a UserForm combo box appears in a form and is managed through VBA. It is also distinct from a Combo Box inserted directly on a worksheet; that control has its own setup and linkage options. The term “combo” reflects that a combo box can combine a list with an editable text field, although the Style property can make it selection-only.
UserForms and their VBA code are features of desktop Excel, not Excel for the web. A workbook can be opened in the web app, but its VBA macros do not run there. This guide focuses on Excel for Microsoft 365 on Windows.
Add a combo box to a UserForm
If the Developer tab is hidden, enable it through File > Options > Customize Ribbon and select Developer. Open the Visual Basic Editor using Developer > Visual Basic, or press Alt+F11 in Windows. On a Mac, the Visual Basic Editor can be opened from Tools > Macro > Visual Basic Editor; keyboard shortcuts can vary with the keyboard and macOS settings.
- In the Visual Basic Editor, choose Insert > UserForm. Excel creates a form, commonly named UserForm1.
- Show the Toolbox if it is not visible by choosing View > Toolbox.
- Select the ComboBox control in the Toolbox, then click or drag on the form to place it.
- Click the new control and set its (Name) property in the Properties window. A useful name is
cmbDepartment. - Add a Label to explain what the user should select. If the form needs a submit action, add a CommandButton and give it a clear caption such as Save.
Use the control’s (Name) property in code; its displayed text is controlled separately. Keeping meaningful names makes procedures easier to read than code that refers to ComboBox1. Save the workbook as an Excel Macro-Enabled Workbook (.xlsm) if it must retain VBA.
Choose how the list is populated
For a short, fixed list, code can add each choice directly with the AddItem method. For a list maintained by workbook users, load the options from a worksheet range instead. A range can be updated without changing the VBA procedure every time a department or product is added. A third option is to set the control’s RowSource property to a worksheet range, but that ties the control directly to that range and can be less convenient when the list needs filtering or more involved preparation.
- AddItem: Convenient for a small list or values assembled by code. It is easy to skip blanks or apply rules as items are loaded.
- Worksheet range with VBA: A flexible choice for workbook-managed lists. VBA can read the range and add only acceptable values.
- RowSource: A quick link to a range when the source is stable and a direct connection is sufficient. The range address must be valid for the form’s context.
For most maintained lists, keep the source values in a clearly named worksheet and explain whether blank rows or duplicates are allowed. If the source list is on a protected or hidden sheet, confirm that the macro can still read it and that workbook users can maintain the list through an appropriate process.
Populate the combo box from worksheet data
This example assumes a worksheet named Lists, department names in A2:A downward, and optional department codes in column B on the same rows. The UserForm contains a combo box named cmbDepartment. Its two columns will show the department name and code; the first column is the value returned as the selection. Put this procedure in the UserForm’s code module, not in a regular worksheet module.
Option Explicit
Private Sub UserForm_Initialize()
Dim ws As Worksheet
Dim lastRow As Long
Dim r As Long
Dim itemIndex As Long
' Read choices from the Lists worksheet when the form opens.
Set ws = ThisWorkbook.Worksheets("Lists")
lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
With Me.cmbDepartment
.Clear
.ColumnCount = 2
.BoundColumn = 1
.ColumnWidths = "120 pt;60 pt"
For r = 2 To lastRow
If Len(Trim$(CStr(ws.Cells(r, "A").Value))) > 0 Then
.AddItem CStr(ws.Cells(r, "A").Value)
itemIndex = .ListCount - 1
.List(itemIndex, 1) = ws.Cells(r, "B").Value
End If
Next r
End With
End Sub
The loop finds the last used row in column A and ignores blank department names. Column indexes in the List property start at zero, so index 0 is the first displayed column and index 1 is the second. BoundColumn is set to 1, meaning the combo box’s Value corresponds to the first displayed column. Change the column widths to suit the actual labels, or use a single column by setting ColumnCount to 1 and removing the code that fills the second column.
The code assumes that the Lists sheet exists. If its name is changed or deleted, the procedure will fail when the form opens. When trying this macro for the first time, save a copy of the workbook before running it: macro changes cannot be undone with Ctrl+Z.
Read and save the user’s selection
To handle a selection, add a CommandButton to the form, name it cmdSave, and place this event procedure in the same UserForm module. It checks that a choice was made, then writes the selected department name to cell B2 on a worksheet named Entry.
Private Sub cmdSave_Click()
If Me.cmbDepartment.ListIndex = -1 Then
MsgBox "Select a department before saving.", vbExclamation
Exit Sub
End If
ThisWorkbook.Worksheets("Entry").Range("B2").Value = _
Me.cmbDepartment.Value
Me.Hide
End Sub
ListIndex is -1 when no list item is selected, which is why it is a useful validation check. If the user should be able to type a new value, decide whether that typed text is acceptable before saving; a value typed into an editable combo box is not necessarily one of the listed items. To return the second-column code instead of the department name, read the appropriate List entry for the selected row rather than assuming Value contains the code. With the example’s two-column list, that code is Me.cmbDepartment.List(Me.cmbDepartment.ListIndex, 1).
To open a form from a workbook, a separate macro can call its Show method using the form’s actual name, for example frmEntry.Show if the form has been renamed frmEntry. The macro can be assigned to a worksheet button or run from the Macro dialog. In the Visual Basic Editor, F5 runs the active procedure when a runnable procedure is selected; it is not a substitute for wiring a Save button’s Click event.
Important properties and behavior
The Properties window controls much of how the combo box looks and behaves. The most useful settings include:
- Style: Determines whether the user can type into the field or must select from the list. Choose a list-only style when arbitrary entries should not be accepted.
- MatchRequired: When applicable to the chosen style, requires typed text to match a list entry. This can help prevent unintended values in an editable combo box.
- ListRows: Sets how many rows are shown in the drop-down at once. A longer list can still be navigated without displaying every item simultaneously.
- ColumnCount and ColumnWidths: Allow more than one field to be displayed, such as a product name beside a product code. A zero-width column can hold a value without showing it, but make sure the visible label remains clear.
- BoundColumn: Specifies which column supplies the control’s Value. Check this setting before assuming Value is the text shown in the first column.
Combo boxes also support events. Change fires when the selected or entered value changes, while Click responds to a click. Use an event only when the form needs to react immediately, such as filling a related text field after a department is chosen. For ordinary submission, validating the selection in the Save button’s Click procedure is often simpler and avoids running the same follow-up logic repeatedly while someone browses the list.
Common problems and fixes
- The list is empty: Confirm that the source sheet name and starting row match the workbook. Check that column A contains values and that the form is loading the intended procedure. A RowSource address that points to the wrong sheet can also leave the list blank.
- The form reports a missing worksheet: The example expects a sheet named Lists exactly. Rename the sheet or change the worksheet name in the code to match.
- The selection returns an unexpected value: Review BoundColumn and ColumnCount. With a multi-column list, Value returns the bound column, not automatically every field displayed beside it.
- Items appear more than once: Initialize runs each time the form is opened. Clear the control before loading items, as the example does, so the list is rebuilt rather than appended to an existing list.
- The macro does not run: Make sure the workbook is saved as .xlsm and that macros are enabled under the organization’s security policy. Do not enable macros in an untrusted file simply to test a form.
For very large lists, loading every item into a form can be inconvenient. Consider narrowing the choices, adding a search field that filters results, or using worksheet-based data entry instead. A combo box is best when its choices are manageable and the form’s workflow adds value beyond a cell drop-down.
UserForm combo box versus worksheet drop-down
Choose a UserForm combo box when you want a custom dialog with several inputs, validation, dependent fields, or a controlled save action. It gives VBA code a central place to check the entry and write it to a chosen destination. It also requires a macro-enabled workbook and users who can run VBA.
Choose a Data Validation list when the entry belongs directly in a worksheet cell and users do not need a custom form. In desktop Excel for Windows, select the target cell and use Data > Data Validation, then choose List under Allow and specify the source. This option does not require VBA, so it is often easier to share in workbooks where macros are unavailable or disabled. It does not, by itself, provide the same form layout or multi-field interaction.
Worksheet controls are another distinct option. Developer > Insert offers Form Controls and ActiveX Controls on Windows, including combo box options. Their setup and behavior differ from a UserForm control; a Form Control can be linked to a cell, while ActiveX controls have their own properties and VBA events. Avoid selecting one just because it has the same name: first decide whether the list belongs in a worksheet or a dialog.
Platform and security considerations
Excel for the web cannot run VBA UserForms. Excel for Mac has VBA support, but Windows instructions, control availability, and compatibility are not identical across platforms. If a workbook must work on both Windows and Mac, test the actual form and controls in each target Excel version; if recipients use Excel for the web, provide a non-VBA route such as worksheet-based data validation.
Macros can change workbook data, so only run code you understand and trust. Share the workbook in a way that preserves its .xlsm format when macros are needed, and tell recipients what the form does. A UserForm is an interface, not a security boundary: hiding a sheet or restricting a drop-down does not make sensitive data safe from someone who can access the workbook or its VBA project.
Frequently Asked Questions
How do I add a combo box to an Excel UserForm?
Open the Visual Basic Editor, insert a UserForm, show the Toolbox, choose ComboBox, and place it on the form. Set its (Name) property so VBA can refer to it clearly.
How do I populate a UserForm combo box from a range?
Use the UserForm_Initialize event to read the worksheet range when the form opens. You can assign a RowSource range directly or loop through the cells and add entries with AddItem, as in the example above.
How do I get the selected value from a combo box?
Read the control’s Value property, such as Me.cmbDepartment.Value. Check ListIndex first if selecting a list item is required, and review BoundColumn if the list has multiple columns.
Can an Excel UserForm combo box allow typing?
Yes. Its Style setting determines whether the field accepts typed text or is limited to list selection. If typed entries are allowed, validate them before saving if only approved values should be recorded.
Do Excel UserForms work in Excel for the web?
No. Excel for the web does not run VBA macros or display VBA UserForms. Use desktop Excel for the form, or consider a worksheet Data Validation list for a workbook that needs a browser-based entry option.
Related
- Excel Not Tabbing to Next Cell? Fixes That Work
- Media Excel Shortcuts for Images, Links, and Objects
- Average Excel File Size: What to Expect and Why It Varies
Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.
More in VBA & macros
- Excel VBA Activate Sheet: Syntax, Examples, and FixesTo activate a worksheet with VBA, reference it by name and call its Activate method: ThisWorkbook.Worksheets("Summary").Activate. The sheet…
- VBA Excel Send Email in New Outlook: Options That WorkNot directly: Excel VBA’s traditional Outlook automation uses the Outlook COM object model, which New Outlook for Windows…
- Insert a Table in Excel Using VBA: Code and TipsIn Excel for Microsoft 365 on Windows, create a table with VBA by specifying the range that contains…
- Excel VBA: What It Does, How It Works, and When to Use ItExcel VBA is the programming language built into the desktop versions of Microsoft Excel for automating tasks and…
- Excel VBA Data Entry Form With a Picture Box: How It WorksYes. In Excel for Microsoft 365 on Windows, make a VBA UserForm, add an Image control to act…
- Outlook Macros: How to Enable Them Safely in Classic OutlookTo enable VBA macros in classic Outlook for Windows, open File > Options > Trust Center > Trust…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.