+ Reply to Thread
Results 1 to 9 of 9

Restrict the date format entered in a cell

  1. #1
    Forum Contributor
    Join Date
    09-04-2007
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    133

    Restrict the date format entered in a cell

    Hi,

    I am working on a excel sheet where the user has to enter a date.

    Now when the user enters the date in a format than the pre-determined format(say, 03/10.2010), an error message has to pop up.

    fpr ex- my predetermined format is mm/dd/yyyy. If the user enters dd-mmm-yyyy then it has to give an error message "wrong format....."

    I know MACROS have to be used to get this functionality. But iam a novice in macros...

    Any help is appreciated.

    Thanks

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Restrict the date format entered in a cell

    Hello skonduru,

    A few questions....
    1. Is this validation to apply to all cells on the worksheet or just a select range of cells?
    2. Which version of Excel are you using?
    3. Which country is this version of Excel for?

    You should update your user profile to include this information.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Contributor
    Join Date
    09-04-2007
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    133

    Smile Re: Restrict the date format entered in a cell

    hi ross....

    1) the validation applies to a selected range of cells in a colomn.

    2) version of excel- 2003.

    3) Country is US......

    will update my profile today

  4. #4
    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: Restrict the date format entered in a cell

    Maybe like this. Code goes in the Sheet module.
    Please Login or Register  to view this content.
    There's nothing you can do to know that 01/06/2010 was really intended to mean 1 Jun 2010.
    Last edited by shg; 04-22-2010 at 11:34 AM.
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Forum Contributor
    Join Date
    09-04-2007
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    133

    Unhappy Re: Restrict the date format entered in a cell

    Now, how do i integrate this code to my excel sheet?

  6. #6
    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: Restrict the date format entered in a cell

    Put the code in the appropriate Sheet module.

    Adding Code to a Sheet module
    1. Copy the code from the post
    2. Right-click on the tab for the relevant sheet and select View Code. This opens the Visual Basic Editor (VBE) and shows the object module for the selected worksheet.
    3. Paste the code in the window
    4. Press Alt+Q to close the VBE and return to Excel

  7. #7
    Forum Contributor
    Join Date
    09-04-2007
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    133

    Re: Restrict the date format entered in a cell

    thanks for the tip shg....

    now, when I come back to excel and try to run the macro from tools----macros---run---, the macro that's written with the code in this thread, just doesn't show up for some reason....

    as a result i cannot run the macro......

  8. #8
    Forum Contributor
    Join Date
    09-04-2007
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    133

    Re: Restrict the date format entered in a cell

    FINALLY got it to run shg......phew...

    but, is there any way where we can get around the "one at a time" functionality. I mean when i try to copy about 10 dates into the range say,"A10:A20" for which the macro is defined, the program returns" one cell at a time" and terminates.....

    is there any workaround for this, so that the code also works for more than 1 cell at a time..in other words, if i paste 10 date value into the range defined by the macro, it shld still work...

    thanks

  9. #9
    Forum Contributor
    Join Date
    09-04-2007
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    133

    Re: Restrict the date format entered in a cell

    bump......................

+ 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