How to Change a UserForm Name in Excel VBA Without Errors

VBA & macros · Updated November 21, 2026

To change a UserForm’s internal name in Excel for Microsoft 365 on Windows, open the Visual Basic Editor, select the form in Project Explorer, press F4, and edit its (Name) property. Then update any code that refers to the old name and compile the project. This changes the form’s identifier in VBA, not the title displayed on the form; that visible title is its Caption property.

What You’ll Need

  • An Excel workbook containing a VBA UserForm. Save it as a macro-enabled workbook, such as an .xlsm file, if it is not already saved in a macro-enabled format.
  • Access to the workbook’s VBA project. If the project is password-protected or your organization restricts macros, you may need permission before you can edit it.
  • A clear new name that starts with a letter and contains no spaces or punctuation. For example, CustomerEntryForm is suitable; Customer Entry Form is not.

Step-by-Step

  1. Save a working copy of the workbook. Before editing or running VBA, use File > Save As to keep a backup. VBA changes and macro actions cannot be undone with Ctrl+Z, so a copy gives you a straightforward way to recover if you make an unwanted change. Keep the backup somewhere separate from the original if the workbook is important.
  2. Open the Visual Basic Editor. In Excel for Windows, press Alt+F11, or select Developer > Visual Basic on the ribbon. If the Developer tab is not visible, you can enable it through File > Options > Customize Ribbon, then check Developer. On a Mac, open the editor from Developer > Visual Basic or Tools > Macro > Visual Basic Editor, depending on the ribbon and Excel layout. Function keys on Mac keyboards may require the Fn key.
  3. Find the form in Project Explorer. In the editor, locate the correct workbook project, then expand its Forms folder. If Project Explorer is hidden, choose View > Project Explorer; on Windows, Ctrl+R is also a shortcut. Identify the form by selecting it and checking that the form designer shows the form you intend to rename. Work in the correct workbook project if several are open.
  4. Select the UserForm itself, not one of its controls. Click the form’s entry in Project Explorer. If you click a text box, button, or other control in the designer, the Properties window will show that control’s properties instead. The object selected in Project Explorer or the designer is reflected at the top of the Properties window, which is a useful check before changing anything.
  5. Show the Properties window. Press F4 on Windows, or choose View > Properties Window in the Visual Basic Editor. On Mac, use the editor’s View menu if the shortcut does not work. The Properties window lists the selected object’s settings. If it is blank or shows properties such as a button’s Caption, reselect the UserForm itself.
  6. Edit the (Name) property. Find the property written as (Name), usually near the top of the list. Click its value, replace the old identifier with the new one, and press Enter. For example, change UserForm1 to CustomerEntryForm. Use a unique identifier without spaces, hyphens, or other punctuation. The name must not conflict with another object or a reserved VBA word.
  7. Do not confuse (Name) with Caption. The (Name) value is how VBA identifies the form in code. The Caption value is the text displayed in the form’s title bar. If you want the window to show “Customer Details” but want code to refer to it as CustomerEntryForm, set those two properties separately. Changing Caption alone does not rename the form’s VBA identifier.
  8. Review and update references to the old name. Search the project for the old identifier, including code in standard modules, worksheet or workbook modules, and other forms. Update references used to show or create the form, declare a variable as that form type, or unload it. For example, code that used UserForm1.Show should refer to CustomerEntryForm after the rename. Do not replace every matching piece of text automatically: a comment, a string, or a control with a similar name may not be a reference to the form.
  9. Compile and save the project. In the Visual Basic Editor, choose Debug > Compile VBAProject. If compilation stops on an error, correct the reported issue and compile again. Once compilation succeeds, save the workbook from Excel or the editor. Close and reopen the form, or run the workbook’s normal form-opening procedure, to confirm that it still behaves as expected.

For a simple check, a standard module can show a new instance of the renamed form. Replace the example name with the exact value you entered for (Name):

Option Explicit

Public Sub ShowCustomerEntryForm()
    Dim frm As CustomerEntryForm

    ' Create and display a new instance of the renamed form.
    Set frm = New CustomerEntryForm
    frm.Show

    ' Unload the form after it is closed.
    Unload frm
    Set frm = Nothing
End Sub

Save a copy before running a macro like this: macro actions cannot be reversed with Ctrl+Z. The example creates a new instance, so it is useful when you want to control that instance directly. If your workbook already has a form-opening procedure, updating and testing that existing procedure may be more appropriate.

Common Mistakes

  • Changing the caption instead of the name. If the form looks different but the old identifier still appears in code, you probably changed Caption. Edit (Name) to change the VBA identifier.
  • Renaming a control by accident. A selected button or text box has its own (Name) property. Check the selected object shown at the top of the Properties window before editing.
  • Using an invalid or duplicate identifier. A name with spaces or a hyphen will not work as a VBA identifier. A name that conflicts with another project member can cause confusion or compile errors. Choose a distinct, descriptive name such as InvoiceReviewForm.
  • Assuming all old references update automatically. Do not rely on the editor to rewrite every reference elsewhere in the project. Search for the old form name and check each relevant use, including variable declarations and New statements.
  • Changing the form name when only the displayed title needs to change. A rename can require code edits. If the goal is only to change the wording users see, edit Caption instead.

Tips

  • Use a naming pattern. Choose names that make the form’s purpose obvious, such as OrderSearchForm or StaffDetailsForm. Consistent names are easier to find and distinguish from controls and variables.
  • Keep the internal name readable and compact. Avoid spaces and punctuation, and use capitalization to separate words. That makes references easier to scan without affecting the form’s displayed title.
  • Search the whole VBA project. In the editor, use Edit > Find and search for the old identifier. Check the search scope and inspect each result; a matching word may be a comment or a different object rather than a form reference.
  • Compile before handing over the workbook. Compilation can expose a broken reference in code that is not called during your first test. Also test the normal button, menu, or workbook event that opens the form, rather than testing only a temporary procedure.
  • Separate code names from user-facing text. A stable internal name can stay concise while the caption is changed for clarity or localization. Changing the caption does not require code references to be renamed.

Troubleshooting

The Properties window does not show (Name). You may have selected a control, a code pane, or another project item. Click the UserForm’s entry under the correct project’s Forms folder. If the window is missing, open it with View > Properties Window, then check the selected object shown at the top.

The new name is rejected. Remove spaces, hyphens, and punctuation, make sure the first character is a letter, and try a name that is not already used by another form or project member. If a name still causes trouble, use a more specific identifier and avoid VBA keywords.

The project no longer compiles or a form-opening line fails. Search for the old name and inspect every result that is code rather than a comment or a string. Pay particular attention to lines such as As UserForm1, New UserForm1, and UserForm1.Show. Update the identifier, then run Debug > Compile VBAProject again. If the error points to a different line, fix that error before testing the form.

The form’s title bar still shows the old wording. The internal rename does not set the visible title. Select the form, find Caption in the Properties window, and enter the text you want users to see. If the title changes but VBA still reports the old identifier, check that you edited (Name) as well.

The form opens during a test but not from the workbook’s usual control. The temporary test procedure may work while a button, event procedure, or other calling code still refers to the old name. Find the normal entry point and update its reference. Then save, close the editor, and repeat the same action a workbook user would take.

The editor appears to have lost the change. Confirm that you renamed the form in the intended workbook project, then save the workbook in a macro-enabled format. If you closed without saving, reopen the backup or original and repeat the steps. Excel for the web cannot edit or run VBA; use desktop Excel on Windows or Mac for these changes.

Frequently Asked Questions

Does changing a UserForm name change the title users see?
No. The (Name) property changes the form’s identifier in VBA. Change Caption to change the text shown in the form’s title bar.

Will renaming the form automatically update my VBA code?
Do not assume it will. Search for the old identifier, inspect the results, and update code references such as form display statements, variable types, and instance creation. Compile the project to catch references you missed.

Can a UserForm name contain spaces?
No. Use a VBA identifier without spaces or punctuation, and start it with a letter. For example, use CustomerEntryForm as the name and put Customer Entry Form in Caption if that is the wording you want displayed.

Can I change the name after the workbook is in use?
Yes, but update and test every reference to the old name. Make a backup first, compile the project, and test the workbook’s regular form-opening actions before distributing the revised file.

Does this work in Excel for the web?
No. Excel for the web does not provide the VBA editor for renaming or editing UserForms. Open the workbook in desktop Excel for Windows or Mac and make the change in the Visual Basic Editor.

Should I rename the controls too?
Only if you want clearer control identifiers in code. Renaming a UserForm does not rename its buttons, text boxes, or other controls, and changing a control name is a separate edit that may also require updating code.

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.