VBA & Macro Problems

Fix Excel VBA Run-Time Error 91 After an Office Upgrade

John WilsonJohn Wilson Nov 18, 2026 871 views

Question details

The user needs to resolve VBA Run-time error 91 in Excel macros after an Office upgrade.

Fix Excel VBA Run-Time Error 91 After an Office Upgrade
Product
Microsoft Excel and Visual Basic for Applications
Device & OS
Windows 10 reported
Scenario
Running a macro that previously worked in Office 2007 after upgrading Office or Windows.
Observed behavior
The macro displays Run-time error 91, potentially due to a missing reference or an object variable that has not been set.
Before you start

Open the affected workbook in desktop Excel and run macros only if you trust the file and its source. If a macro is running, stop it before changing VBA references.

Solution 1Recommended

Check for missing VBA references

Use this first when a macro stops working after an Office upgrade or when a workbook comes from another computer.

1
Open the VBA editor

In the affected workbook, press Alt+F11 to open the Visual Basic Editor.

2
Find missing references

Select Tools > References and look for checked entries that begin with MISSING:. Note the name of each missing library.

3
Update the references

Clear the checkbox for a missing reference. If the macro needs that library, select an available compatible reference or install the required library, then click OK.

4
Test the macro

Return to Excel and run the macro again from Developer > Macros. If the error remains, click Debug in the error dialog.

Check for missing VBA references
A missing library may be required: Removing a reference alone can cause other errors if the code depends on it. Restore the appropriate library or reference when needed.
Free Microsoft Office alternative

Work with Excel spreadsheets in WPS Office

WPS Office is a free, lightweight alternative with a familiar spreadsheet interface and support for common Excel formats, making it easy to move everyday spreadsheet work. It does not fix Excel's VBA references or guarantee compatibility with existing macros.

Open and edit spreadsheets using a familiar interfaceCompatible with common Microsoft Excel formats, including XLS and XLSXContinue everyday spreadsheet work in a lightweight office suiteMove existing spreadsheet files into WPS Office without starting from scratch
microsoft office alternative - wps office

Frequently Asked Questions

What does VBA Run-time error 91 mean?

It means an object variable or With block variable has not been set. Click Debug in the error dialog to inspect the highlighted code and the object it uses.

Where can I find missing VBA references?

Press Alt+F11 in desktop Excel, then select Tools > References. Look for checked entries beginning with MISSING:.

Should I remove every missing reference?

Note each missing reference before clearing it. If the macro depends on that library, install the required library or select a compatible reference in Tools > References.

Why does the macro still fail after I clear a missing reference?

The macro may still need the library, or the highlighted code may use an object that is Nothing. Click Debug and use View > Locals Window to inspect the object variables.