+ Reply to Thread
Results 1 to 6 of 6

VBA Date Validation?

  1. #1
    Registered User
    Join Date
    11-28-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    73

    VBA Date Validation?

    Hello,

    Trying to user-input-error-proof a new macro w/ UI that I'm building in Word. As far as I can tell, I am unable to use an input mask... So i have the default value of the field as "DD-MMM-YYYY" to clearly hint for the user. But, I would still like to have validation that passes/fails if the user inputs correctly/incorrectly.

    Here's what I'm trying so far just to test in a separate file:

    Please Login or Register  to view this content.
    Not really my first preferred go-to, but I think it could be sufficient. This would validate that a date is entered like "05-Mar-2014". Any other suggestions or am I close to makine this work? Cheers.
    Last edited by jsabo; 08-18-2014 at 07:51 AM.

  2. #2
    Forum Contributor lancer102rus's Avatar
    Join Date
    04-02-2014
    Location
    Ufa
    MS-Off Ver
    Excel 2010, 2013
    Posts
    252

    Re: VBA Date Validation?

    need this?
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    11-28-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    73

    Re: VBA Date Validation?

    So, is it that simple? If the user puts ANY date format in a text box... and I declare oDate to be a Date... then I can simply change the way the VBA displays it?

  4. #4
    Forum Contributor lancer102rus's Avatar
    Join Date
    04-02-2014
    Location
    Ufa
    MS-Off Ver
    Excel 2010, 2013
    Posts
    252

    Re: VBA Date Validation?

    Yes. It is so.

  5. #5
    Registered User
    Join Date
    11-28-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    73

    Re: VBA Date Validation?

    Thanks for your help!

  6. #6
    Registered User
    Join Date
    11-28-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    73

    Re: VBA Date Validation?

    So, here is where I am now:

    Please Login or Register  to view this content.
    First the code looks to see if it's actually a date that's input. If not, it forces the the user to put in a date. Then I try to assign the value of the text box to a certain variable and dictate the format "DD-MMM-YYYY". But, whenever the date is spit out it is not DD-MMM-YYYY, rather M/D/YY. Any ideas?

    EDIT:

    Got it working here, this makes more sense and is more efficient too:

    Please Login or Register  to view this content.
    Last edited by jsabo; 08-19-2014 at 03:27 AM. Reason: Solved

+ 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. Userform Validation if date is within 2 weeks of todays date
    By Mackattack in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-19-2014, 07:50 AM
  2. [SOLVED] Data Validation won't accept Start Date and End Date from cell values.
    By SpecialBrew in forum Excel General
    Replies: 12
    Last Post: 03-16-2014, 10:23 PM
  3. Adding Date Data Validation to cells with List Data Validation
    By biggtyme in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-03-2013, 09:47 AM
  4. Date and count validation in single cell - Custom Validation
    By murugavelmsc in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-16-2013, 05:25 AM
  5. Date Validation - Must equal Sundays date
    By jeridbohmann in forum Excel General
    Replies: 14
    Last Post: 11-30-2005, 04:45 PM

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