ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Neutral date format in VBA (https://www.excelbanter.com/excel-programming/340199-neutral-date-format-vba.html)

Balex

Neutral date format in VBA
 
Hi,

I have an Excel macro that checks a document property which is a date. I am
checking a given date, which, if set, triggers a given processing. How can I
design my if statement so that the check is always working regardless of the
locale of the user running Excel, i.e. if I want to check if the date is
equal to the 15th of August 2005, how should my if statement look like ?

Thanks for help
Balex

Tom Ogilvy

Neutral date format in VBA
 
if cdate(stringvariable) = DateValue("August 15, 2005") then

--
Regards,
Tom Ogilvy

"Balex" wrote in message
...
Hi,

I have an Excel macro that checks a document property which is a date. I

am
checking a given date, which, if set, triggers a given processing. How can

I
design my if statement so that the check is always working regardless of

the
locale of the user running Excel, i.e. if I want to check if the date is
equal to the 15th of August 2005, how should my if statement look like ?

Thanks for help
Balex




William[_2_]

Neutral date format in VBA
 
Hi Balex

Try.....

Dim d as Date
d=DateSerial(2005,8,15)
If Date = d then
'Your Code here
End If


--

XL2003
Regards

William



"Balex" wrote in message
...
Hi,

I have an Excel macro that checks a document property which is a date. I
am
checking a given date, which, if set, triggers a given processing. How can
I
design my if statement so that the check is always working regardless of
the
locale of the user running Excel, i.e. if I want to check if the date is
equal to the 15th of August 2005, how should my if statement look like ?

Thanks for help
Balex




Bob Phillips[_6_]

Neutral date format in VBA
 
If CDate(mydatestring) = #2005-08-15# Then
...

--
HTH

Bob Phillips

"Balex" wrote in message
...
Hi,

I have an Excel macro that checks a document property which is a date. I

am
checking a given date, which, if set, triggers a given processing. How can

I
design my if statement so that the check is always working regardless of

the
locale of the user running Excel, i.e. if I want to check if the date is
equal to the 15th of August 2005, how should my if statement look like ?

Thanks for help
Balex





All times are GMT +1. The time now is 02:27 PM.

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