+ Reply to Thread
Results 1 to 6 of 6

Mask for a Cell/Field of a form

  1. #1
    Registered User
    Join Date
    09-06-2012
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    11

    Mask for a Cell/Field of a form

    Hello,

    How can I add a mask that would make faster the input of a year between 2000 and 2018.

    I was thinking of something like this "20"00 resulting in something like that "20__" for the user.

    The problem is that if I also use the data validation (between 2000 and 2018), Excel won't detect any mistakes.

    I wonder if there is any excel built in solution. If not, I can use VBA. Any Ideas?

    Thank you,

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Mask for a Cell/Field of a form

    Why won't data validation detect a mistake if a number between 2000 & 2018 isn't entered? That's precisely what data validation does.

    Or are you saying you want the user to enter a number between 0 and 18 and the cell to result in 2000....2018?

    In which case a sheet change event procedure like the following. Change the A1 reference as necessary.

    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    09-06-2012
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Mask for a Cell/Field of a form

    Quote Originally Posted by Richard Buttrey View Post

    Or are you saying you want the user to enter a number between 0 and 18 and the cell to result in 2000....2018?

    Yes. I did accomplish by using a custom mask in the cell's property ("20"00), which worked, but the data validation parameter (between 2000 and 2018) was not detecting any mistakes.

    Applying this code to the needed range will most likely work, thank you.

    I wonder, however, why didn't the data validation worked?

    If type "19", and he apply the filter, it would be a invalid parameter. If type "19", then he transform it into 2019, and then apply the filter, it would be invalid as well... But he didn't worked in any of those case...

    Cheers

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: Mask for a Cell/Field of a form

    Quote Originally Posted by Et_Dux_ View Post
    ...I did accomplish by using a custom mask in the cell's property ("20"00), which worked, but the data validation parameter (between 2000 and 2018) was not detecting any mistakes....
    That is because the cell ONLY contains what you type in, and not (necessarily) what it shows. So if you type 20, thats all the cell contains - 20. the rest is just a visual display of how you want it shown.

    Another example is if you format a cell to only snow 2 decimal places, and enter 1.23456789, it will only show 1.23, but will still contain that full number
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  5. #5
    Registered User
    Join Date
    09-06-2012
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Mask for a Cell/Field of a form

    Got it. Thank you.

  6. #6
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: Mask for a Cell/Field of a form

    Happy to help

+ 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. Copy Data from form field and paste into worksheet cell
    By azhark in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-18-2013, 04:47 PM
  2. Part of mask from cell ref
    By somesoldiers in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-30-2012, 10:14 AM
  3. [SOLVED] Input mask on a form in Excel 2003
    By Lloyd in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-25-2006, 10:10 AM
  4. Cell input mask
    By Dan N in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-08-2006, 04:10 PM
  5. Placing a mask within a cell
    By Brian in forum Excel General
    Replies: 5
    Last Post: 06-24-2005, 06:05 PM
  6. Mask / Format a cell
    By Fable in forum Excel General
    Replies: 3
    Last Post: 03-26-2005, 05:55 PM
  7. Can I set an input mask for a cell?
    By Choro in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-18-2005, 11:11 PM

Tags for this Thread

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