Troubleshoot VBA Code Failures in Excel 2016 and Microsoft 365
Question details
Identify why VBA code that works in Excel 2010 fails in Excel 2016 or Excel for Microsoft 365.

- Product
- Microsoft Excel 2016 and Excel for Microsoft 365
- Device & OS
- not provided
- Scenario
- A user runs an existing Excel 2010 macro in a newer version of Excel.
- Observed behavior
- The VBA code fails in the newer Excel version; the exact error or failing behavior has not been provided.
In the affected Excel installation, open File > Account > About Excel and note the version, build, and whether Excel is 32-bit or 64-bit. Use a trusted macro-enabled workbook and record any error message and the action that triggers it.
Debug the macro and check VBA compatibility
Use this method first to find the failing line and identify version, reference, or declaration issues.
Open the workbook in the Excel version where the macro fails, then select Developer > Visual Basic or press Alt+F11 on Windows.
In the VBA editor, select Debug > Compile VBAProject. Correct any syntax or compilation error highlighted by the editor.
Place the cursor in the affected procedure and select Debug > Step Into, or press F8, to run it one line at a time. Record the highlighted line and the complete error message when it fails.
In the VBA editor, select Tools > References and look for entries marked MISSING. Restore the required library or update the code and reference to use a compatible library.
Inspect the failing line and related code for unavailable methods or library differences. If the macro calls Windows APIs in 64-bit Excel, review Declare statements for PtrSafe and appropriate pointer-sized types such as LongPtr.

Check workbook format and macro security settings
Use these checks if the macro does not run or the workbook opens with a security warning.
Repair Office or investigate the Microsoft 365 update channel
Consider these options after documenting the failure and checking the code and workbook settings.
Work with spreadsheets in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface and Microsoft Office format compatibility, making it easy to move everyday spreadsheet work between suites. It does not repair Excel's VBA installation, and macro compatibility should be tested separately.

Frequently Asked Questions
Why does my Excel 2010 macro fail in a newer version?
The cause may be a missing library reference, a method or declaration that behaves differently, macro security, or another compatibility issue. In the affected Excel version, use the VBA editor's Debug > Step Into command to locate the failing line.
How do I find a missing VBA reference?
Open the VBA editor and select Tools > References. Look for an entry marked MISSING, then restore the required library or update the project to use a compatible reference.
Can 64-bit Excel cause an older macro to fail?
It can, particularly if the macro calls Windows APIs using declarations intended for 32-bit Excel. Check File > Account > About Excel for bitness, then review API declarations for PtrSafe and pointer-sized types where appropriate.
What should I do if Excel blocks the macro?
Read the workbook's security warning and enable content only if you trust its source. On Windows, you can review the applicable settings under File > Options > Trust Center > Trust Center Settings > Macro Settings; organizational policies may also apply.
Will switching Microsoft 365 update channels fix the code?
Not necessarily. First document the error and installed build under File > Account > About Excel. If the installation is managed, ask your IT administrator whether testing another supported channel is appropriate.




