ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Xl2007 Conditional Constants (https://www.excelbanter.com/excel-programming/382923-xl2007-conditional-constants.html)

Josh Sale

Xl2007 Conditional Constants
 
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



JLatham

Xl2007 Conditional Constants
 
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




Josh Sale

Xl2007 Conditional Constants
 
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






Chip Pearson

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








Josh Sale

Xl2007 Conditional Constants
 
Thanks Chip.

I figured that was the case ...



Bob Phillips

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









All times are GMT +1. The time now is 07:26 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com