Display the version number of Excel using VBA


This snippet displays the version number of Excel using VBA.
On Windows Vista with Excel 2007 it gives 12.0 for example.
On Windows 10 with Excel 2016 it gives 16.0.

Here is the definitive version from Office.com

What version of Office am I using?


Sub sbVersion()
 Dim xlVersion As String
 xlVersion = Application.Version
 MsgBox xlVersion
 If xlVersion = "12.0" Then MsgBox "Excel 2007"
 If xlVersion = "16.0" Then MsgBox "Excel 2016"
End Sub


Tags - Microsoft Excel VBA, version number, Excel 2007, Excel 2016