+ Reply to Thread
Results 1 to 8 of 8

Determine cells date format

  1. #1
    Forum Contributor
    Join Date
    11-28-2008
    Location
    Reykjavík, Iceland
    MS-Off Ver
    Any of: 2003 & 2007
    Posts
    412

    Determine cells date format

    Hi,

    How can I determine a cells date format in VBA ?

    I want to return TRUE for only one particular format which is: dd/mm/yyyy and FALSE for all! other formats.

    dd/mm/yy, dd.mm.yy, dd.mm.yyyy, mm/dd/yy etc, should return FALSE

    I have tried:

    Please Login or Register  to view this content.

    but the Msgbox poped-up even for 23/11/1999

    Thanks, Elm
    Last edited by ElmerS; 07-29-2010 at 01:52 PM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Determine cells date format

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Contributor
    Join Date
    11-28-2008
    Location
    Reykjavík, Iceland
    MS-Off Ver
    Any of: 2003 & 2007
    Posts
    412

    Re: Determine cells date format

    Thank you.

    I changed the format while you were replying, so I tried: "dd/mm/yyyy".

    Something very strange happens here.

    I checked in two different computers and it returns FALSE.

    In both computers the 23/11/1999 returns: m/d/yyyy with: MsgBox Range("A1").NumberFormat

    Do you think it has to do with it being an European Format - or...?

    Elm
    Last edited by ElmerS; 07-28-2010 at 06:12 PM.

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Determine cells date format

    Perhaps:

    Please Login or Register  to view this content.
    would work for you ?

    edit: probably not actually ... it's not a format specific test I guess.

  5. #5
    Forum Contributor
    Join Date
    11-28-2008
    Location
    Reykjavík, Iceland
    MS-Off Ver
    Any of: 2003 & 2007
    Posts
    412

    Re: Determine cells date format

    Thanks.

    No, it does not.

    It returns True for: 23.11.1999 as well

    Elm

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Determine cells date format

    It returns False for me if running client on Icelandic regional - on which locales are you running this ?

    You might also want to investigate NumberFormatLocal property.

    Handling dates and date formats is often a PITA in XL.

  7. #7
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Determine cells date format

    Hi ElmerS,
    The spammer title will be reversed - Apologises for the mistake
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  8. #8
    Forum Contributor
    Join Date
    11-28-2008
    Location
    Reykjavík, Iceland
    MS-Off Ver
    Any of: 2003 & 2007
    Posts
    412

    Re: Determine cells date format

    Thanks, DO,

    So far so good with NumberFormatLocal.

    Hopefully it wont give me unexpected or wrong results in the future.

    Elm

+ Reply to 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