+ Reply to Thread
Results 1 to 8 of 8

Converting String to Date with DateValue, then testing for T/F

  1. #1
    Registered User
    Join Date
    05-29-2013
    Location
    IL, USA
    MS-Off Ver
    Excel 2010
    Posts
    27

    Converting String to Date with DateValue, then testing for T/F

    hello again.

    I am trying to check my sheet names to see if they convert to a valid date format. If it doesn't, then I want it to check for the next criteria (ex - if it equals "Page2"). With the code below I keep getting an error of type mismatch. Any help would be greatly appreciated. Code is below.


    Please Login or Register  to view this content.
    Last edited by JoshExcel; 03-10-2014 at 10:10 PM. Reason: Solved

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,604

    Re: Converting String to Date with DateValue, then testing for T/F

    Please Login or Register  to view this content.
    Ben Van Johnson

  3. #3
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Converting String to Date with DateValue, then testing for T/F

    You may also use:
    Please Login or Register  to view this content.
    • Please remember to mark threads Solved with Thread Tools link at top of page.
    • Please use code tags when posting code: [code]Place your code here[/code]
    • Please read Forum Rules

  4. #4
    Registered User
    Join Date
    05-29-2013
    Location
    IL, USA
    MS-Off Ver
    Excel 2010
    Posts
    27

    Re: Converting String to Date with DateValue, then testing for T/F

    ok, maybe I'm just a little thick, but I don't see how that will loop through all the worksheets in the workbook. I may have left that part off in my original post though.

    Here is my revised code to try to use what proton suggested.

    I still receive the error message of 13 "Type Mismatch" on the "dateTester = DateValue(dateText)". I even tried to call dateTester as a Boolean, then checking for False, but I still get the Mismatch message. All suggestions are welcomed.

    Please Login or Register  to view this content.
    Last edited by JoshExcel; 03-10-2014 at 07:24 PM.

  5. #5
    Registered User
    Join Date
    05-29-2013
    Location
    IL, USA
    MS-Off Ver
    Excel 2010
    Posts
    27

    Re: Converting String to Date with DateValue, then testing for T/F

    I even tried to incorporate Izandol's suggestion, but keep getting the type mismatch error.

  6. #6
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Converting String to Date with DateValue, then testing for T/F

    Where does error occur using IsDate function?

  7. #7
    Registered User
    Join Date
    05-29-2013
    Location
    IL, USA
    MS-Off Ver
    Excel 2010
    Posts
    27

    Re: Converting String to Date with DateValue, then testing for T/F

    ****well, it usually works better if I remove the ' in order for it to execute that line of code. Updated code soon to follow.

    whether I use Not IsDate(dateText), or what I have below, it doesn't loop the way I want it to. Basically, I want it to update all the sheets, unless the text can convert to a date, or if the text = "Effic", "Veps Util", "OU", "Prod" or "Quality". All the other sheets get an extra column added.

    Please Login or Register  to view this content.
    Last edited by JoshExcel; 03-10-2014 at 09:32 PM.

  8. #8
    Registered User
    Join Date
    05-29-2013
    Location
    IL, USA
    MS-Off Ver
    Excel 2010
    Posts
    27

    Re: Converting String to Date with DateValue, then testing for T/F

    Here is the functioning code. Thanks Izandol!

    Please Login or Register  to view this content.
    Last edited by JoshExcel; 03-10-2014 at 10:10 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Converting text string that contains a date and time to a date
    By jmforde in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-12-2013, 02:31 PM
  2. Trying to use DateValue to extract date from string
    By mindtheGaspar in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-28-2013, 07:01 PM
  3. Converting a date serial number back to a date within a string
    By bharris77 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-22-2012, 01:15 PM
  4. Excel and VBA keep converting my string to a date.
    By foxguy in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 08-08-2010, 07:08 PM
  5. [SOLVED] Converting Date to Text String
    By John Calder in forum Excel General
    Replies: 3
    Last Post: 04-08-2005, 07:06 AM

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