You can create a UserForm in Excel by opening the Visual Basic Editor (Alt+F11), inserting a UserForm, dragging controls onto it, and writing a short VBA macro to show it. This gives you a custom dialog box for data entry, filtering, or running macros — no need to edit cells directly. The steps below use Excel for Windows; on Mac, the VBA editor is similar but some controls and shortcuts differ, and UserForms are not available in Excel for the web.
What You'll Need
- Excel for Windows or Mac (desktop version). UserForms are not supported in Excel for the web or mobile apps.
- The Developer tab enabled: File > Options > Customize Ribbon, then tick Developer in the right-hand list. On Mac: Excel > Preferences > Ribbon & Toolbar.
- Macro security set to allow macros in the workbook (you'll be prompted to enable content when you reopen the file).
- A workbook saved as .xlsm (macro-enabled) — otherwise your VBA code will be lost.
Step-by-Step
- Open the Visual Basic Editor. Press Alt+F11 (on Mac, Fn+Alt+F11 or use Tools > Macro > Visual Basic Editor). A separate window opens.
- Insert a UserForm. In the VBE menu, choose Insert > UserForm. A blank grey form appears, along with the Toolbox (if the Toolbox is hidden, choose View > Toolbox).
- Add controls from the Toolbox. Click a control (Label, TextBox, ComboBox, CommandButton) and drag it onto the form. Use the Properties window (F4) to change Name, Caption, and other settings. Give meaningful names like txtName, cboDepartment, btnSubmit — you'll reference these in code.
- Arrange and align. Select multiple controls and use Format > Align or Format > Make Same Size. Set the form's Caption (the title bar text) in the Properties window.
- Write the code behind the form. Double-click a button (e.g., btnSubmit) to open the code window. Add a Click event that validates inputs and writes to a worksheet. Example:
This appends each entry to the next empty row on the Data sheet and clears the fields.Private Sub btnSubmit_Click() If Trim(txtName.Value) = "" Then MsgBox "Please enter a name." Exit Sub End If Dim ws As Worksheet Set ws = ThisWorkbook.Sheets("Data") Dim r As Long r = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row + 1 ws.Cells(r, 1).Value = txtName.Value ws.Cells(r, 2).Value = cboDepartment.Value txtName.Value = "" cboDepartment.Value = "" End Sub - Add a Cancel or Close button. Insert another CommandButton, name it btnClose, and in its Click event put
Unload Me. That closes the form without saving. - Create a macro to show the form. In the VBE, choose Insert > Module and add:
Replace UserForm1 with your form's actual name if you renamed it.Sub ShowDataForm() UserForm1.Show End Sub - Run it. Close the VBE, press Alt+F8, select ShowDataForm, and click Run. The form appears; fill it in and click Submit. Check the Data sheet — the row should be there.
- Add a button on the sheet (optional). On the Developer tab, click Insert > Button (Form Control), draw it on the sheet, and assign the ShowDataForm macro. Now anyone can open the form with one click.
- Save as .xlsm. File > Save As, choose Excel Macro-Enabled Workbook. If you save as .xlsx, the UserForm and code are stripped out.
Common Mistakes
- Saving as .xlsx. The form disappears on reopen. Always use .xlsm.
- Using default control names. TextBox1, CommandButton1 get confusing fast; rename controls before writing code.
- Forgetting to Unload Me. The form stays open or the macro appears to hang. Add a Close button.
- No input validation. Empty fields or text in a number field cause errors later. Check values in the Click event before writing to the sheet.
- Referencing the wrong sheet name. If the sheet tab is renamed,
Sheets("Data")fails. Use the exact tab name or the sheet's code name. - Macro security blocking the form. If nothing happens when you click the button, check the yellow security bar and enable content.
Tips
- Use a ComboBox with a fixed list (set RowSource in Properties or add items in code) to prevent typos in categories.
- Set TabIndex on controls so users can Tab through fields in a logical order.
- Add a Label at the top with instructions, and set the form's Caption to something descriptive.
- Keep the form small — one purpose per form is easier to maintain than a giant multi-tab dialog.
- Test with the VBE open and use F8 to step through code line by line when something misbehaves.
- If you need the form on many workbooks, consider an Excel add-in (.xlam) instead of copying code.
Troubleshooting
The form doesn't appear when I run the macro. Check that the macro name matches and that UserForm1.Show refers to the correct form name. Also confirm macros are enabled.
Compile error: Method or data member not found. A control name in your code doesn't match the Name property on the form. Open the Properties window and compare spelling exactly.
Data goes to the wrong sheet or row. Verify the sheet name in Sheets("Data") matches the tab exactly, including spaces. For row calculation, ensure column A is the one you want to check for the last row.
The form opens but buttons do nothing. Double-check that the Click event code is in the UserForm's code module, not a standard module. Events must live with the form.
Mac users see a different Toolbox or missing controls. Some ActiveX controls are Windows-only. Stick to the standard Toolbox controls (TextBox, ComboBox, CommandButton, Label) for cross-platform compatibility.
I get a 'Macro may be disabled' warning. Enable content via the yellow bar, or adjust Trust Center settings (File > Options > Trust Center > Trust Center Settings > Macro Settings). Only enable macros in files you trust.
Frequently Asked Questions
Can I use a UserForm in Excel for the web?
No. UserForms require the desktop VBA editor. In Excel for the web you can use data validation and forms, but not custom VBA dialogs.
Do I need to know VBA to build a UserForm?
You can design the form without code, but it won't do anything until you add at least a Show macro and button Click events. Basic VBA is required for it to be useful.
How do I make the form save data to a specific row?
In the button's Click event, find the last used row with Cells(Rows.Count, 1).End(xlUp).Row + 1 and write to that row. Adjust the column number to match your data layout.
Can I add a date picker to a UserForm?
The Microsoft Date and Time Picker control is not included by default in recent Office versions. A common alternative is a TextBox with a date format check, or a ComboBox listing dates. Third-party controls exist but aren't required.
Why does my form reset when I reopen the workbook?
If you saved as .xlsx, the form was removed. Save as .xlsm. Also check that the form wasn't accidentally deleted from the VBA project.
Can multiple people use the same UserForm at once?
UserForms run locally in each person's Excel session. For shared data entry, store the data in a shared workbook or a database, and be aware that simultaneous writes can conflict. Excel's co-authoring does not support VBA forms.