View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_3_] Dave Peterson[_3_] is offline
external usenet poster
 
Posts: 2,824
Default Excel Version Trap

I think your test depends on going back to excel's worksheet. And then excel's
parser takes over and sees that entry as numeric.

But if you stay in VBA:
Option Explicit
Sub testme()

Dim myArr As Variant
Dim iCtr As Long
myArr = Array(3.3, "3.3", Application.Version, Val(Application.Version))

Debug.Print "Ctr Val VBA FromWks"
For iCtr = LBound(myArr) To UBound(myArr)
ActiveSheet.Range("a1").Value = myArr(iCtr)
Debug.Print iCtr & "--" & myArr(iCtr) & "--" & TypeName(myArr(iCtr)) _
& "--" & Application.IsNumber(ActiveSheet.Range("a1").Value )
Next iCtr

End Sub
Returned:
Ctr Val VBA FromWks
0--3.3--Double--True
1--3.3--String--True
2--10.0--String--True
3--10--Double--True



Gord Dibben wrote:

Application.Version returns a numeric, not a string.

It does not differentiate between releases(x,y,z etc.)as far as I can tell.

Sub version()
Range("A1").Value = Application.Version
End Sub

=ISNUMBER(A1) returns TRUE

Tested on versions 8.0, 10.0 and 11.0

Don't know how we got from VBA to worksheet Functions....

Your original question was......

I am looking for a listing of MS Excel verions (releases). I have searched
"all of Microsoft.com" to no avail. Specifically I want to keep a VBA
procedure from running if the user has anything less than releases 9.0x or
10.0x. The procedure creates a Pivot Table and Pivot Chart which requires the
aforesaid two versions. I was considering using a Select Case statement that
would result in an appropriate message box and "Exit Sub" unless a version
that handles Pivot Charts is being used. Thanks in Advance!

Gord

On Sat, 12 Jun 2004 15:26:01 -0700, "amescha"
wrote:



"Gord Dibben" wrote:

If Application.Version < "9.0" Then
MsgBox "This utility will not work in your version of Excel. " & _
"You must upgrade to version 9.0.", vbExclamation
End
End If

Gord Dibben Excel MVP

Dear Gord,

Well this code works fine on the current platform that I am using, namely excel version 8.0e. I will not have the opportunity to try version 9.0x & 10.0x until next week. Stay tuned.
My question here is that I am given to understand that the application.version
property returns a String. It is obvious that string "values" are being compared here. The question then becomes what happens when I try this on a 10.0x platform. When I type =IF(H3<I3,TRUE,FALSE) on a worksheet and enter 8.0e in cell H3 and 9.0x in cell I3 I see a TRUE but when cell I3 becomes 10.0z or 10 as a number then I see FALSE.
Could you please elaborate if you have the time?
Thanks in advance - again
amescha


--

Dave Peterson