Fix Excel 2016 VBA Macros That Fail in Excel 2007
Question details
Identify why a VBA macro that works in Excel 2016 produces errors in Excel 2007.

- Product
- Microsoft Excel 2016 and Excel 2007
- Device & OS
- not provided
- Scenario
- A workbook containing VBA macros is opened in Excel 2007 after working in Excel 2016.
- Observed behavior
- The macro produces errors in Excel 2007.
Have access to Excel 2007 and the workbook's VBA project. Note the exact error message and the highlighted line of code, and enable macros only if you trust the workbook.
Check VBA references and compile the project in Excel 2007
Use this method to identify missing libraries and code that Excel 2007 cannot compile.
Open the workbook in Excel 2007 and press Alt+F11 to open the VBA editor.
Select Tools > References and look for entries marked MISSING. Identify the library used by the affected code, then select an available compatible version or revise the code to avoid the unavailable library.
Select Debug > Compile VBAProject. Review the highlighted line and error message, correct the issue, and compile again until no compile errors remain.
Return to Excel, select Developer > Macros or press Alt+F8, and run the affected macro. Record any remaining error and the line highlighted by Debug.
Replace features and declarations that Excel 2007 does not support
Use this method when the error points to a newer Excel feature, worksheet function, or Windows API declaration.
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 easier to move everyday spreadsheet work between applications. It does not fix Excel's VBA compatibility issues, and macro support can vary by WPS edition and platform.

Frequently Asked Questions
How do I find a missing VBA reference in Excel 2007?
Press Alt+F11 to open the VBA editor, then select Tools > References. Look for any checked entry marked MISSING and determine whether the code needs a compatible library or a code change.
Can an Excel 2016 worksheet function cause a macro to fail in Excel 2007?
Yes. A macro that calls a worksheet function introduced after Excel 2007 may fail in the older version. Check the failing line and replace the function with an alternative supported by Excel 2007.
Why do Windows API declarations need special attention?
Declarations must match the API signature and the target architecture. VBA7 supports PtrSafe and LongPtr, while Excel 2007 uses an older VBA version, so conditional compilation may be needed for code shared across versions.
What should I provide if the macro still fails?
Record the exact error message, the Excel version, and the code line highlighted after you select Debug. Include the relevant procedure and any missing references shown under Tools > References.




