View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default Xl2007 Conditional Constants

Josh,

There is no such conditional compilation constant. At compile time, there
is no way to determine what version of Excel you are using. There is, of
course, the VBA6 compiler constant, but that applies to everything since
2000.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)




"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