To find the version of Excel currently running using VBA, use the Application.Version property. This property returns a string representing the version number of the Excel application (for example, "16.0" for Excel 2016, 2019, 2021, and Office 365). This is essential for developers who need to ensure their code is compatible with the specific version of Excel the end-user is utilizing, as certain functions or objects may not exist in older versions.

What You'll Need

  • A computer with Microsoft Excel installed.
  • The Developer tab enabled in the Excel Ribbon.
  • Basic familiarity with opening the Visual Basic Editor (VBE).

Step-by-Step

  1. Open the Visual Basic Editor: Launch Microsoft Excel. Press Alt + F11 on your keyboard. This keyboard shortcut opens the VBE window regardless of which sheet you are currently viewing.
  2. Insert a New Module: In the VBE menu, go to Insert and then select Module. This creates a blank space where you can write your custom procedures without affecting the code tied to specific sheets or the workbook object.
  3. Create a Subroutine: Type the following line to start your macro: Sub CheckExcelVersion(). Press Enter to move to the next line.
  4. Write the Version Command: To simply see the version number in a popup box, type: MsgBox Application.Version. The Application object refers to the entire Excel instance, and .Version is the specific property that holds the version string.
  5. Close the Subroutine: Type End Sub on a new line to tell VBA where the code block ends.
  6. Run the Macro: You can run the code by pressing F5 while your cursor is inside the subroutine, or by returning to the Excel window, going to the Developer tab, clicking Macros, selecting CheckExcelVersion, and clicking Run.
  7. Interpret the Result: A message box will appear displaying a number like "16.0". Note that since the release of Excel 2016, Microsoft has used "16.0" for multiple versions, including Office 365, Excel 2019, and Excel 2021. To distinguish between these, you may need to check other properties or the build number.

Common Mistakes

One of the most frequent errors is treating Application.Version as a numeric value rather than a string. Because it returns a string (e.g., "16.0"), attempting to perform mathematical comparisons like If Application.Version > 15 Then can sometimes lead to type mismatch errors or unexpected results depending on how VBA handles the implicit conversion. The correct way to compare versions is to use the Val() function, which converts the string to a number: If Val(Application.Version) >= 16 Then.

Another mistake is confusing Application.Version with the build number. The version number tells you the major release (like 16.0), but it does not tell you the specific update or build of Office 365. If your code relies on a feature introduced in a specific monthly update of Office 365, Application.Version will not be granular enough to identify if that feature is available.

Users also frequently forget to save their workbook as an Excel Macro-Enabled Workbook (.xlsm). If you write the code in a standard .xlsx file and save it, all your VBA modules—including the version check—will be permanently deleted when the file is closed.

Tips

For professional deployment, avoid using MsgBox to display the version. Instead, assign the version to a variable at the start of your project. This allows you to use the variable throughout your code to enable or disable specific features based on the user's version. For example: Dim excelVer As Double: excelVer = Val(Application.Version).

If you need to handle compatibility across very old versions (like Excel 2003 or 2007) and modern versions, consider using Application.Version in conjunction with #If...Then...#End If conditional compilation constants. However, these constants are defined at compile time, whereas Application.Version is checked at runtime, making the latter more flexible for distributed tools.

To make your version check more robust, you can create a custom function that returns a user-friendly name. For instance, you can write a function that takes Application.Version and returns "Excel 2013" if the value is "15.0" or "Excel 2016+" if it is "16.0".

Troubleshooting

If the code does not run or you receive an error, first check if macros are enabled. Go to File > Options > Trust Center > Trust Center Settings > Macro Settings and ensure that macros are not completely disabled. If they are, you will not be able to execute any VBA code.

If you receive a "Compile error: Variable not defined," it is likely because you have Option Explicit at the top of your module. This is a good practice, but it means you must declare every variable. Ensure you have used Dim to declare any variable you are using to store the version string.

If Application.Version returns a value you don't recognize, remember that Microsoft's versioning numbering system is not always intuitive. For example, Excel 2010 is 14.0, Excel 2013 is 15.0, and everything from 2016 onwards generally reports as 16.0. If you are seeing a number like "12.0", you are likely running Excel 2007.

If the VBE window is frozen or not responding, save your work in the main Excel window first, then use the Task Manager to end the Excel process and restart the application. This often clears memory glitches associated with the VBA editor.

Frequently Asked Questions

Does Application.Version distinguish between Excel 2019 and Office 365?

No, both Excel 2019 and Office 365 (along with 2016 and 2021) typically return "16.0". To differentiate these, you would need to check for the existence of specific functions (like XLOOKUP) using Application.FunctionExists or by checking the registry.

Can I use this to check the version of another open Excel workbook?

The Application object refers to the current instance of Excel. Since all open workbooks in a single instance share the same version of the Excel application, Application.Version will be the same for all of them.

Is Application.Version a string or a number?

It is a string. Even though it looks like a number (e.g., "16.0"), VBA treats it as text. Always use Val() or CDbl() if you intend to use it in a mathematical comparison.

Will this work on Excel for Mac?

Yes, Application.Version works on both Windows and macOS versions of Excel, though the specific version numbers returned may occasionally differ based on the Mac release cycle.

Can I use this to detect 32-bit vs 64-bit Excel?

No, Application.Version only reports the release version. To detect if Excel is 32-bit or 64-bit, you must use conditional compilation constants like #If Win64 Then.