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)




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




  • Select Custom




  • In Formula box, enter the formula as



  • 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


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.