+ Reply to Thread
Results 1 to 2 of 2

Data Validation with Text, 3 digits maximum. Problems with leading zeros.

  1. #1
    Forum Contributor
    Join Date
    12-15-2009
    Location
    Herndon, VA
    MS-Off Ver
    Excel 2010
    Posts
    163

    Data Validation with Text, 3 digits maximum. Problems with leading zeros.

    In cell D5, I want to capture an entry of 3 digits max. If the number entered is less than 100, leading zeros should automatically return. So if the user entered 3 it would show as 003. If they entered 30, it would show as 030.

    In D5, I also have Data Validation as Text Length with a max of 3 digits.

    In cell D6 I want to capture the value in D5, i.e. 003, 030, 300, etc.




    In cell D5 I have set up a cell with Data Validation using Text Length for the Validation Criteria. It has been limited to "Less than or Equal to" = 3 so I can restrict entries to 3 digits.

    In cell D6 I am referencing the result in D5 with TEXT($D$5,"000").

    Here is the problem. If I enter 0003 I should get an error message because I have entered more than 3 characters. But the leading zero gets dropped off and the result in the cell is 003. I want it to flag this as an error because it is a 4 digit entry . One way to correct this is to change the cell format to Text. But if I do that and enter 3 in D5, it shows as 3 instead of 003 which I don't want.

    It's as if Data Validation ignores leading zeros and cuts things down to the 3 digit maximum.

    So one fix results in another problem.

    Any ideas on how to get Excel to recognize 0003 as a four digit entry?

  2. #2
    Forum Contributor
    Join Date
    06-09-2011
    Location
    Germany
    MS-Off Ver
    Excel 2016
    Posts
    194

    Re: Data Validation with Text, 3 digits maximum. Problems with leading zeros.

    Hi,

    I understand the entries are always Numbers. If that is the case, you could change the data validation (in D5) from length to whole numbers with 0 as minimum and 999 as max. You could even change the numberforat in D5 to 0000 (using format cells-number format - custom and set it to 0000).

    Should the user enter 0003, it would automatically be converted to 003.

    Hope this helps

    Theo
    Remember To Do the Following....
    1. Upload sample files
    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.

+ 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