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

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
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:
Upvote 0
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.
 
Upvote 0
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?
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,223,731
Messages
6,174,173
Members
452,548
Latest member
Enice Anaelle

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
Back
Top