VBA Tip: Perform an Action Depending on Excel's Version

To determine the version of Excel of the user, and thus perform a different action depending on the version in use, you can use Val(Application.Version) which returns (the number of) the version of Excel.


Here are the versions numbers of Excel to be used to conduct tests:

8Excel 97 (Mac: 98)
9Excel 2000 (Mac: 2001)
10Excel 2002
11Excel 2003 (Mac: 2004)
12Excel 2007 (Mac: 2008)
14Excel 2010 (Mac: 2011)
15Excel 2013 (Mac: 2016)
16Excel 2016

For example to test if the version of Excel is inferior to 2007, you may use this code:

If Val(Application.Version) < 12 Then
    'If version of Excel is inferior to 2007
Else
    'If version of Excel is equal or superior to 2007
End If