+ Reply to Thread
Results 1 to 7 of 7

ISDATE function in VBA evaluating to false and i dont know why

  1. #1
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,680

    ISDATE function in VBA evaluating to false and i dont know why

    Hi, i have a macro where i use the vba function ISDATE.

    I pass the isdate function two date formats.........but for some reason both evaluate to "false" and i am not sure why.

    i am enclosing small macro to show the problem i am having........

    Any ideas?
    Attached Files Attached Files

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: ISDATE function in VBA evaluating to false and i dont know why

    Try declaring the variables as dates

    Please Login or Register  to view this content.
    Martin

  3. #3
    Valued Forum Contributor
    Join Date
    08-13-2012
    Location
    Gardony, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    558

    Re: ISDATE function in VBA evaluating to false and i dont know why

    Hi,

    you are using the Value2 property and it returns a Double data type if the original data in the range is Date. Try using the Value property.
    http://msdn.microsoft.com/en-us/libr...ice.11%29.aspx

    Note: you didn't declare some of your variables, not sure if that's intentional.

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: ISDATE function in VBA evaluating to false and i dont know why

    If you change this line

    Please Login or Register  to view this content.
    INTO
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,680

    Re: ISDATE function in VBA evaluating to false and i dont know why

    thanks....i will take a look at your suggestions

    during the time i posted this question........the server went dead for this web site...........during that time i was thinking about what to do.......

    i came up with this idea of a validDate function.........it seems to work......i am going to include it below.......but it figures that i would go to a "long" soln when (looking at the suggestions thus far) when the real soln might be very simple.

    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,680

    Re: ISDATE function in VBA evaluating to false and i dont know why

    this is not the first time i have run across the ".value" vs ".value2" issue.

    Any suggestions on when to use one vs the other? I read something somewhere that i should always use the ".value2" which is why i use it all the time.......but from time to time when working with dates i have an issue but not all the time.

    any suggestions/advice?

  7. #7
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: ISDATE function in VBA evaluating to false and i dont know why

    if you need dates to be treated as dates (and currency to be treated as such) use value otherwise use value2. the latter is often faster and can be safer if you may run into conversion issues such as date formatting-which is only an issue with non US formats and text representations of dates
    Josie

    if at first you don't succeed try doing it the way your wife told you to

+ 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