+ Reply to Thread
Results 1 to 6 of 6

Check user input format

  1. #1
    Registered User
    Join Date
    10-10-2012
    Location
    Virginia, USA
    MS-Off Ver
    Excel 2003
    Posts
    12

    Check user input format

    Hello!

    I'm trying to find a way to verify that user input is in a specific format (specifically "mm/dd/yyyy"). Here's what I got:

    Please Login or Register  to view this content.
    Any help is greatly appreciated, thanks!

  2. #2
    Registered User
    Join Date
    10-10-2012
    Location
    Virginia, USA
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Check user input format

    ttt

    *bump*

  3. #3
    Valued Forum Contributor
    Join Date
    05-21-2009
    Location
    Great Britain
    MS-Off Ver
    Excel 2003
    Posts
    550

    Re: Check user input format

    Please Login or Register  to view this content.
    Post responsibly. Search for excelforum.com

  4. #4
    Registered User
    Join Date
    10-10-2012
    Location
    Virginia, USA
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Check user input format

    Thank you, Chippy

    After I read your post, I realized where I went wrong. I was using the Like function at first, but I was using "Loop While" instead of "Loop Until." Of course, VBA wasn't accepting anything in that date format, but it was accepting everything that wasn't in the format. So tedious, my logic.

  5. #5
    Registered User
    Join Date
    11-09-2009
    Location
    london, england
    MS-Off Ver
    Excel 2010
    Posts
    52

    Re: Check user input format

    In addition to Chippy's suggested code. It is worth checking that the date is valid by using IsDate VBA function. This will ensure that the user has not incorrectly entered an invalid date (e.g. 29/02/2011, 31/09/2012), which can easily be done as there is no validation on the input.

  6. #6
    Registered User
    Join Date
    10-10-2012
    Location
    Virginia, USA
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Check user input format

    Thank you, ducky

    A combination of the LIKE with the added ISDATE method is exactly what I was looking for. Now, the code checks for a date in a specific format using dual nested DO LOOPS. A rather short solution, I might add.

+ 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