Fix Excel VBA Run-Time Error 91 After an Office Upgrade
Question details
The user needs to resolve VBA Run-time error 91 in Excel macros 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.
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.
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.
In the affected workbook, press Alt+F11 to open the Visual Basic Editor.
Select Tools > References and look for checked entries that begin with MISSING:. Note the name of each missing library.
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.
Return to Excel and run the macro again from Developer > Macros. If the error remains, click Debug in the error dialog.

Inspect the object highlighted by the VBA debugger
Use this if the error persists after checking references or if no missing reference is listed.
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.

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.




