VBA & Macro Problems

How to Fix Excel VBA UserForm Arguments Runtime Error

Bushra ParveenBushra Parveen Nov 2, 2026 871 views

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.

How to Fix Excel VBA UserForm Arguments Runtime Error
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 you start

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.

Solution 1Recommended

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.

1
Open the VBA Editor

Press Alt + F11 in Excel to open the Visual Basic for Applications (VBA) editor.

2
Locate the procedure

Find the Sub or Function procedure that accepts the UserForms as arguments. Check the current parameter declarations.

3
Update parameter types

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`.

4
Compile the VBA project

Go to Debug > Compile VBAProject in the top menu to ensure there are no syntax or reference errors before running the code again.

Correct the UserForm Parameter Data Types
Tip: Always pass UserForms `ByRef` (which is the default in VBA) rather than `ByVal` to ensure you are modifying the actual instance of the form.
Free Microsoft Office alternative

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. 1. Download WPS Office: Visit the official WPS Office website and download the free installation package.
  2. 2. Install the software: Run the installer and follow the on-screen instructions to set up WPS Office on your computer.
  3. 3. Open your spreadsheet: Launch WPS Spreadsheet and open your existing Excel workbooks to enjoy seamless compatibility.
Highly compatible with Microsoft Excel formats (.xlsx, .xlsm, .csv)Free, lightweight, and fast to installFamiliar ribbon interface for seamless user migrationBuilt-in PDF editing and cloud collaboration tools
QA img-9

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.