View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 1,726
Default Xl2007 Conditional Constants

You can't, it is not an conditional constant.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Josh Sale" <jsale@tril dot cod wrote in message
...
Thanks. I'm familiar with Application.Version. What I want is a
conditional constant so I can write something like:

#If VBA12 Then
.....
#End If

So that the compiler won't even try to compile the enclosed code on
earlier versions of Excel.

j




"JLatham" <HelpFrom @ Jlathamsite.com.(removethis) wrote in message
...
Application.Version is what I've been using. Excel 2007 is Excel 12, and
Application.Version will return "12.0" in it. You can use that in a
number
of ways:

If Left(Application.Version,2)="12" then
'in Excel 2007
Else
'not in Excel 2007
End IF

or

If Val(Application.Version) <12 Then
'not in Excel 2007
Else
'in Excel 2007 (or later)
End If

Practical example dealing with the 'stardard' test to find last used row
in
a column

Dim LastUsedRow As Long
If Val(Application.Version) <12 Then
'not in Excel 2007
LastUsedRow = Rows.Count
Else
'in Excel 2007 (or later)
LastUsedRow = Rows.CountLarge
End If
then you can use LastUsedRow like this later on without having to do
further
version testing:
LastRowValue = Range("A" & LastUsedRow).End(xlUP).Value


"Josh Sale" wrote:

Does anybody know if there has been any additions to the built-in
conditional constants in Excel 2007?

In particular, I'm hoping for one that distinguishes XL2007 from
previous
versions.

TIA,

josh