Reset UserForm VBA: Clear Controls and Restore Defaults

VBA & macros · Updated November 18, 2026

In Excel VBA, reset a UserForm by setting its input controls back to blank or to chosen defaults. For a fresh form instance, use Unload and show it again; hiding a form does not reset its controls.

What “reset” means in a VBA UserForm

“Reset” can describe several different outcomes, and choosing the right one matters. You might want to clear fields so a person can enter another record, restore the form’s original default selections, or discard the entire form instance and start over. These approaches are not interchangeable: a control-clearing routine changes selected values, while unloading removes the current form instance.

A UserForm can also hold state that is not visible in its controls. For example, code may store a record identifier in a module-level variable, change a label’s caption, enable or disable a button, or retain a selected tab. Clearing text boxes alone will not necessarily undo those changes. A complete reset should identify all the state that the form is expected to restore.

For an ordinary “New entry” button, explicitly clearing the editable controls is usually the most predictable approach. It lets you leave instructions, labels, and other static interface elements intact. Use unloading when you specifically want the form to be closed and rebuilt on its next display.

Clear common controls with a Reset button

Open the UserForm’s code module in the Visual Basic Editor, add a button such as cmdReset, and create its Click event. The example below clears text boxes, deselects combo boxes and list boxes, and turns off check boxes, option buttons, and toggle buttons. It covers controls placed directly on the form; nested controls are handled in the next section.

Before running any macro, save a copy of the workbook. VBA macros cannot be undone with Ctrl+Z, so a reset that affects bound or otherwise connected data may not be reversible through Excel’s Undo command.

Private Sub cmdReset_Click()
    Dim ctl As Object

    ' Clear common input controls placed directly on this form.
    For Each ctl In Me.Controls
        Select Case TypeName(ctl)
            Case "TextBox"
                ctl.Value = vbNullString
            Case "ComboBox"
                ctl.ListIndex = -1
                ' Clear typed text only for an editable combo box.
                If ctl.Style = 0 Then ctl.Value = vbNullString
            Case "ListBox"
                ctl.ListIndex = -1
            Case "CheckBox", "OptionButton", "ToggleButton"
                ctl.Value = False
        End Select
    Next ctl
End Sub

The combo box check distinguishes an editable drop-down from a list-only drop-down. In a list-only control, clearing its selection is the goal; setting its value to an arbitrary blank string can be inappropriate when the control only accepts items from its list. If a control is bound to a worksheet range or another data source, test the reset carefully because changing its value may also change that source.

Reset controls inside Frames and MultiPage tabs

A loop over Me.Controls reaches controls directly on the UserForm, but does not automatically walk into every container. Text boxes inside a Frame or on a MultiPage page are children of that container. If your form uses those layouts, a recursive routine can visit the nested controls as well.

The following version includes Frames, Pages, and MultiPage controls. Put both procedures in the UserForm’s code module, then have the Reset button call ResetControls Me.Controls. The helper resets input controls but leaves labels, images, and other unlisted control types alone.

Private Sub cmdReset_Click()
    ' Visit controls on the form and inside its containers.
    ResetControls Me.Controls
End Sub

Private Sub ResetControls(ByVal controls As Object)
    Dim ctl As Object
    Dim i As Long

    For Each ctl In controls
        Select Case TypeName(ctl)
            Case "TextBox"
                ctl.Value = vbNullString
            Case "ComboBox"
                ctl.ListIndex = -1
                If ctl.Style = 0 Then ctl.Value = vbNullString
            Case "ListBox"
                For i = 0 To ctl.ListCount - 1
                    ctl.Selected(i) = False
                Next i
                ctl.ListIndex = -1
            Case "CheckBox", "OptionButton", "ToggleButton"
                ctl.Value = False
            Case "Frame", "Page"
                ResetControls ctl.Controls
            Case "MultiPage"
                For i = 0 To ctl.Pages.Count - 1
                    ResetControls ctl.Pages(i).Controls
                Next i
        End Select
    Next ctl
End Sub

This routine deliberately does not clear every control indiscriminately. A label’s caption may explain what to enter, and a list box may contain choices that should remain available even when its selection is cleared. If your form contains other input types, such as a spin button or scroll bar, add a specific case for that control and decide the correct reset value rather than assuming all controls share a usable Value property.

Restore defaults instead of leaving fields blank

Many forms need a useful starting state rather than an entirely empty one. A date field might start with today’s date, a department combo box might select a common choice, or one option button might represent the usual answer. The safest pattern is to separate clearing from default assignment: first clear the relevant inputs, then set the intended defaults explicitly.

For example, after the reset routine, you could set a date text box to a chosen date format and select an item by its list index. List indexes begin at zero, so index zero means the first item, not the second. If the list can change order, find the desired item by its displayed value or populate it consistently before assigning the selection. Do not assume a particular item exists without checking.

You may also put the default assignments in a separate procedure, such as SetFormDefaults, and call it after the clearing procedure. This makes the behavior easier to maintain: the reset button can call both procedures, while a “Clear all” button can call only the clearing routine. Keep non-input changes in the same default procedure when they are part of the expected starting state, including captions, enabled states, and selected tabs.

Reset on initialization, hide, and unload

The UserForm’s Initialize event runs when that form instance is loaded. Calling your reset or defaults procedure from this event is a practical way to configure a newly loaded form. A typical pattern is to call SetFormDefaults from UserForm_Initialize, then call it again from a Reset button when the user needs to start a second entry.

Hide merely makes the current form invisible. Its controls and other instance state remain in memory, so showing that same instance again can display the previous entries. This is useful when code needs to read values after the form closes, but it is not itself a reset.

Unload Me, when used inside the form, unloads the current instance. When the form is loaded again, its initialization event runs for the new load. For example, a close button can unload the form, while a button intended to keep the form available can use Me.Hide. Choose based on whether other code still needs to retrieve the values; unloading too early can discard data that the calling procedure expected to read.

Common problems and careful checks

  • Some fields do not clear: Check whether those controls are inside a Frame or MultiPage, and use a routine that traverses the relevant containers. Also verify the control’s actual type in the VBA editor.
  • A combo box behaves differently from a text box: A list-only combo box accepts selections from its list, while an editable combo box can contain typed text. Reset selection and typed text in a way that matches its Style and data source.
  • A list box still shows its choices: Clearing the selection does not remove the list’s items. That is normally desirable. Remove items only when the list itself should be rebuilt or emptied.
  • Option buttons return to an unexpected choice: Option buttons may be grouped by their container or GroupName setting. After clearing or changing a group, explicitly assign the intended default and test the group’s behavior.
  • A field changes a worksheet cell: Look for a control’s ControlSource or code that writes to cells. A reset can affect linked data, so test on a copy and decide whether the source should also be restored.
  • A reset button clears itself or other interface text: Avoid blanket rules that erase every control’s Value. Target known input types and leave labels, prompts, and display-only fields alone unless they are deliberately part of the reset.

Choosing a reset method

Use a control-by-control routine when the form stays open and the user is entering multiple records. It is explicit, preserves the current form, and allows meaningful defaults to be set immediately. It is also easier to tailor: perhaps the form should clear a name and address but keep the customer category selected.

Use Hide when the calling code needs to inspect the form’s entries after it disappears, or when temporarily hiding it is part of the workflow. Use Unload when the form should close and its instance state should be discarded. For either lifecycle method, be deliberate about which form instance your code refers to, especially in projects that create instances with the New keyword rather than relying on the default instance.

There is no universal reset command that knows what “initial” means for every custom form. A form’s initial state is a design decision: blank, prefilled, partly selected, or populated from a record. Writing that state into a dedicated procedure is often clearer and more reliable than expecting an automatic reset to infer it.

Frequently Asked Questions

How do I clear all text boxes in a VBA UserForm?
Loop through the form’s controls, test for controls whose type is TextBox, and assign vbNullString to each text box’s Value. If text boxes are inside Frames or MultiPage tabs, include a recursive traversal of those containers.

Does hiding a UserForm reset it?
No. Me.Hide makes the current instance invisible but preserves its control values. Clear the controls explicitly, or unload the form and load it again if you want a new instance.

Does UserForm_Initialize run every time I show the form?
It runs when the form instance is initialized as it is loaded, not every time an already-loaded, hidden instance is shown. Put reset behavior in a separate procedure and call it whenever you need the form restored.

How do I clear a ListBox without removing its items?
Clear its selection, for example by setting each item’s Selected property to False for a multi-select list box, and set ListIndex to -1. Do not use a method that removes the list entries if you want the choices to remain.

Can I reset a UserForm with one command?
There is no built-in command that can infer all of a custom form’s intended defaults. Write a procedure that clears or assigns each relevant control, or unload and reload the form when discarding the entire instance is appropriate.

Related

Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.

More in VBA & macros

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.