Data Validation Allow Particular Numbers & Specific Length

If you are required to add particular numbers with specific length in a range then you can make use of data validation. In this article, we will focus on extensive use of data validation custom feature to allow user to enter only x length & specific numbers and not all of them.

 

Question: I am using data validation, but I’m not able to help myself as my request is a little hard. I want excel to allow up to 5 digits & the digits that should be allowed are only 1,2,3,4,5,6 which implies 0,7,8,9 should not be allowed. In case user enters more than 5 digits or user enter any of the non-allowed digits, then excel must notify user with an alert message.

 

The functions we are going to use are AND, ISNUMBER, LEN, ISERROR & FIND.

We need to follow the below steps:

  • Select the range where we want to apply data validation (A1:D10 in our example)

 

img1

 

  • Press ALT + D + L to open Data Validation box

 

img2

 

  • Select Custom

 

img3

 

  • In Formula box, enter the formula as
  • =AND(ISNUMBER(--A1),LEN(A1)<6,ISERROR(FIND("0",A1)),ISERROR(FIND("7",A1)),ISERROR(FIND("8",A1)),ISERROR(FIND("9",A1)))

 img4

 

  • The entire formula is not visible; in order to check, you can use mouse cursor; do not use keyboard arrows, this will cause error in formula
  • Click on Ok button

 

Conclusion: In this way, we can use data validation to allow user to enter specific numbers with specific length.

 

image 48

 

If you liked our blogs, share it with your friends on Facebook. And also you can follow us on Twitter and Facebook.
We would love to hear from you, do let us know how we can improve, complement or innovate our work and make it better for you. Write us at info@exceltip.com

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Terms and Conditions of use

The applications/code on this site are distributed as is and without warranties or liability. In no event shall the owner of the copyrights, or the authors of the applications/code be liable for any loss of profit, any problems or any damage resulting from the use or evaluation of the applications/code.