How to Fix VBA UserForm Run-Time Error 9 in Excel
Question details
The user encounters Run-Time Error 9 when attempting to open or call a VBA UserForm.

- Product
- Excel / WPS Spreadsheet
- Device & OS
- not provided
- Scenario
- Running a VBA macro to open a UserForm.
- Observed behavior
- The macro execution halts and displays Run-Time Error 9, typically caused by referencing a form or object name that does not match the actual project name.
Ensure you have saved a backup of your macro-enabled workbook (.xlsm) before modifying the VBA code to prevent accidental data loss.
Verify and Update UserForm Name References
Check the VBA Project Explorer to ensure the exact UserForm name is being called in your macro.
Run-time Error 9 often occurs when the VBA procedure references a form name that is misspelled or does not match the actual name defined in the project.
Press Alt + F11 on your keyboard to open the Visual Basic for Applications (VBA) Editor.
Look at the Project Explorer pane on the left side of the screen. Expand the 'Forms' folder to see all UserForms in your project.
Check the exact spelling of the UserForm you want to open (e.g., VIEW_WEEKLY_SCHEDULE_FORM). You can also click the form and check the '(Name)' field in the Properties window below.
Open the module or sheet code containing the click event that calls the form. Update the .Show command to match the exact form name (e.g., VIEW_WEEKLY_SCHEDULE_FORM.Show).

Check Control Initialization Code
Ensure that all controls referenced during the UserForm's activation or initialization actually exist on the form.
Use WPS Spreadsheet for Seamless VBA Macro Execution
WPS Office provides robust support for VBA macros, allowing you to create, edit, and run UserForms smoothly. It offers a familiar VBA Editor interface, making it easy to debug errors like Run-Time Error 9.
- 1. Open your Macro Workbook: Launch WPS Spreadsheet and open your .xlsm file.
- 2. Access the Developer Tools: Go to the 'Developer' tab on the ribbon and click 'VBA Editor'.
- 3. Debug the UserForm: Use the Project Explorer to verify your UserForm names and run the debugger to fix Error 9.

Frequently Asked Questions
What does Run-Time Error 9 mean in VBA?
Run-Time Error 9 typically means 'Subscript out of range'. In the context of UserForms, it occurs when the code tries to reference a form, sheet, or array element that does not exist or is misspelled.
How do I find the real name of my UserForm?
Open the VBA Editor (Alt + F11), look at the Project Explorer pane on the left, expand the 'Forms' folder, and check the name listed next to the form icon. You can also select the form and check the '(Name)' property in the Properties window.
Why does my UserForm work on one computer but give Error 9 on another?
This can happen if the macro relies on specific worksheet names, external files, or add-ins that are present on the first computer but missing or named differently on the second computer. Check your initialization code for external references.




