How to Fix Excel VBA UserForm Arguments Runtime Error
Question details
The user needs to resolve a VBA runtime error and an issue where UserForm captions become blank after passing two UserForms as arguments to a procedure.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Running an Excel VBA procedure that receives two UserForm objects as arguments to process and delete a record.
- Observed behavior
- The record deletes successfully, but a runtime error triggers at the end of the execution, and the UserForm captions unexpectedly turn blank in the called procedure.
Before modifying your VBA object references and code logic, ensure you have saved a backup copy of your macro-enabled workbook (.xlsm) to prevent any accidental data or code loss.
Correct the UserForm Parameter Data Types
Ensure the UserForms are passed using the correct object reference types to prevent memory release issues that cause blank captions and runtime errors.
Passing a UserForm by its specific name can sometimes cause VBA to create a hidden new instance of the form rather than referencing the existing one. Changing the parameter type to a generic object prevents this.
Press Alt + F11 in Excel to open the Visual Basic for Applications (VBA) editor.
Find the Sub or Function procedure that accepts the UserForms as arguments. Check the current parameter declarations.
Change the parameter types from a specific form name to generic objects. For example, modify it to `Sub ProcessRecord(frm1 As MSForms.UserForm, frm2 As MSForms.UserForm)` or simply use `As Object`.
Go to Debug > Compile VBAProject in the top menu to ensure there are no syntax or reference errors before running the code again.

Use UserForm.Hide Instead of Unload
If a UserForm is unloaded from memory while another procedure still holds a reference to it, its properties (like Captions) will drop, causing runtime errors when accessed.
Try WPS Office for a Lightweight and Compatible Spreadsheet Experience
If you are tired of troubleshooting complex Microsoft Office Excel VBA errors, consider using WPS Office. It provides excellent compatibility with Microsoft formats, a familiar user interface, and is completely free to use for your daily spreadsheet tasks.
- 1. Download WPS Office: Visit the official WPS Office website and download the free installation package.
- 2. Install the software: Run the installer and follow the on-screen instructions to set up WPS Office on your computer.
- 3. Open your spreadsheet: Launch WPS Spreadsheet and open your existing Excel workbooks to enjoy seamless compatibility.

Frequently Asked Questions
Why does my VBA macro throw a runtime error only at the end of the procedure?
This typically happens when the procedure tries to return to the calling code, but the objects or UserForms referenced in the parameters have already been destroyed or unloaded from memory, causing an invalid reference error.
Why do my UserForm captions turn blank during VBA execution?
Blank captions occur when the UserForm object loses its state. This is often caused by implicitly re-initializing the form (calling it after it was unloaded) or experiencing memory reference issues when passing it incorrectly as an argument.
Can I run my macro-enabled Excel workbooks (.xlsm) in WPS Office?
Yes, WPS Office offers excellent format compatibility with Microsoft Office. The premium versions of WPS Office fully support VBA macros, allowing you to run, edit, and troubleshoot .xlsm files seamlessly.




