Closed Thread
Results 1 to 4 of 4

Neutral date format in VBA

  1. #1
    Balex
    Guest

    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

  2. #2
    Tom Ogilvy
    Guest

    Re: Neutral date format in VBA

    if cdate(stringvariable) = DateValue("August 15, 2005") then

    --
    Regards,
    Tom Ogilvy

    "Balex" <Balex@discussions.microsoft.com> wrote in message
    news:E91A0DA2-04E5-43E1-BA21-B06E55A0B794@microsoft.com...
    > 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




  3. #3
    William
    Guest

    Re: 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
    willwest22@yahoo.com


    "Balex" <Balex@discussions.microsoft.com> wrote in message
    news:E91A0DA2-04E5-43E1-BA21-B06E55A0B794@microsoft.com...
    > 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




  4. #4
    Bob Phillips
    Guest

    Re: Neutral date format in VBA

    If CDate(mydatestring) = #2005-08-15# Then
    ...

    --
    HTH

    Bob Phillips

    "Balex" <Balex@discussions.microsoft.com> wrote in message
    news:E91A0DA2-04E5-43E1-BA21-B06E55A0B794@microsoft.com...
    > 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




Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1