How to Fix Excel VBA Run-Time Error 13 on Different Computers
Question details
The user's Excel VBA macro works properly on their home computer but triggers a Run-time error 13 on a work computer. The affected workbook also utilizes FILTER formulas.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Running a macro-enabled workbook containing modern dynamic array functions on computers with different software versions.
- Observed behavior
- The macro throws Run-time error 13 (Type Mismatch) on the work computer, and the FILTER formulas may display #NAME? errors due to version incompatibility.
Before altering your VBA code, verify the exact Microsoft Office versions installed on both computers, as formula incompatibilities frequently trigger cascading VBA errors.
Check Excel Version and Formula Compatibility
Identify if the work computer uses an older version of Excel that lacks support for newer functions like FILTER, which causes #NAME? errors that VBA cannot process.
Run-time error 13 often occurs when VBA tries to read a cell value that contains a formula error. If a workbook uses the FILTER function (introduced in Microsoft 365 and Office 2021) and is opened in an older version of Excel, the formula returns a #NAME? error. When the macro references this cell, a Type Mismatch occurs.
Open Excel on the work computer, click on 'File', and select 'Account' to view the exact product version and release year.
Check your workbook for cells displaying #NAME? or #VALUE! errors, particularly those using dynamic array formulas like FILTER.
If you cannot update Office, replace the FILTER function with backwards-compatible formulas (like INDEX and AGGREGATE) so the cells calculate correctly without triggering macro errors.

Debug and Compile the VBA Code
Use the built-in VBA debugger to locate the exact failing line and enforce proper data typing and object references.
Run Macros and Dynamic Arrays Seamlessly in WPS Spreadsheet
If downgrading your formulas to accommodate older versions of Excel is not ideal, you can open your workbook in WPS Spreadsheet. It seamlessly supports VBA macros and modern dynamic array functions like FILTER, preventing the version-related errors that trigger VBA type mismatches.
- 1. Install WPS Office: Download and install WPS Office Free on your computer.
- 2. Open the workbook: Launch WPS Spreadsheet and open your macro-enabled workbook.
- 3. Run your macros: Navigate to the Developer tab, enable macros, and run your VBA scripts without triggering legacy version errors.

Frequently Asked Questions
What does VBA Run-time error 13 Type Mismatch mean?
Run-time error 13 occurs when VBA attempts to assign a value to a variable that conflicts with its declared data type. For instance, trying to perform mathematical operations on text, or attempting to read a cell that currently displays an error value like #NAME?.
Why does the FILTER function show a #NAME? error on my work computer?
The FILTER function is a modern dynamic array function introduced in Microsoft 365 and Excel 2021. If your work computer runs an older version of Excel (like Excel 2016 or 2019), it will not recognize the function and will output a #NAME? error.
How can I prevent Type Mismatch errors when reading cell values in VBA?
You can prevent this by adding error-handling logic in your code. Before processing a cell's value, use the IsError(Range("A1").Value) function to check if the cell contains an error. Additionally, use explicit type conversion functions (like CStr or CDbl) to guarantee the incoming data matches your variable's type.




