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:
8 | Excel 97 (Mac: 98) |
9 | Excel 2000 (Mac: 2001) |
10 | Excel 2002 |
11 | Excel 2003 (Mac: 2004) |
12 | Excel 2007 (Mac: 2008) |
14 | Excel 2010 (Mac: 2011) |
15 | Excel 2013 (Mac: 2016) |
16 | Excel 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