VBA test for finding Excel version?

9tanstaafl9

Well-known Member
Joined
Mar 23, 2008
Messages
535
Is there a way in vba to test to see what version of Excel is being used?
My macro would crash if their data would exceed the 65K row limit in Excel 2003. I have a message that pops up if they do that, and it handles the problem just fine, but if they are ALREADY using Excel 2007 (or whatever comes later) I don't want the message to appear.

How do I test?

Jennifer
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

9tanstaafl9

Well-known Member
Joined
Mar 23, 2008
Messages
535
Application.Version

12.0 = Excel 2k7

Thank you. So how would I use that exactly? (Still on my first project here...)

Would this be right to test for Excel 2007 or later?
Code:
if application.version >= 12.0 then 
     'code goes here
end if

Thanks. I'd test it myself but I'm using 2003.
 
Last edited:

gauntletxg

Well-known Member
Joined
Jul 15, 2008
Messages
636
It depends on what you want to do, but there's really no need to check if the version is greater than 12.0. If you only want your code to run if the user has 2007, just check for = 12.0.
 

9tanstaafl9

Well-known Member
Joined
Mar 23, 2008
Messages
535

ADVERTISEMENT

Ok, but when I enter 12.0 VBA changes the code to read 12# Is that what is supposed to happen?

I'm actually trying to make sure they have 2007 OR LATER so I don't have to redo the code if they upgrade someday. I suppose testing for if what they are running = Excel 2003 instead would work. Do you happen to know the version number for 2003?
 
Joined
Jul 30, 2006
Messages
3,656
9tanstaafl9,

Code:
Sub ReturnExcelVersion()
    If Application.Version = "12.0" Then
        MsgBox "You are using Excel 2007."
    ElseIf Application.Version = "11.0" Then
        MsgBox "You are using Excel 2003."
    ElseIf Application.Version = "10.0" Then
        MsgBox "You are using Excel 2002."
    ElseIf Application.Version = "9.0" Then
        MsgBox "You are using Excel 2000."
    ElseIf Application.Version = "8.0" Then
        MsgBox "You are using Excel 97."
    ElseIf Application.Version = "7.0" Then
        MsgBox "You are using Excel 95."
    End If
End Sub


Have a great day,
Stan
 

9tanstaafl9

Well-known Member
Joined
Mar 23, 2008
Messages
535
Thank you both. I've got it now. Sorry if this was a dumb one, but the search terms were too generic for me to find anything (or my searches were anyway). I appreciate the help. --Jennifer
 

G12

Board Regular
Joined
Nov 11, 2008
Messages
113
Office Version
  1. 365
Platform
  1. Windows
Perfect. This is exactly what I needed to see also. Solved different problem and, for the record, if someone else looks back at this Excel 2010 is ?Application.Version = 14.0
 

Watch MrExcel Video

Forum statistics

Threads
1,129,824
Messages
5,638,540
Members
417,033
Latest member
JKThai

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top