Thread: Data Validation
View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.misc
Sloth
 
Posts: n/a
Default Data Validation

Your problem is how Excel stores numbers (particulary the case with leading
zeros). 01234567 is not an 8-digit number. Even if you apply a custom
format of 00000000, and enter the value as 01234567, the cell value is still
the number 1234567. You have two options depending on whether you want to
allow leading zeros or not. I know that both of these have already been
suggested, but I just thought it might help to clarify the difference between
the two.

I. With leading zeros.
you will HAVE to format the cell as text and use a custom data validation of
=ISNUMBER(--A1)*(LEN(A1)=8)*(--A1=0)
Usually this is not a problem because you can still do most mathematical
operators with text that contain only digits. You might have to change
formulas like SUM(A1:A10) to SUMPRODUCT(--A1:A10).

II. Do not allow leading zeros.
Allow Whole numbers between 10000000 and 99999999.



"Connie Martin" wrote:

I want to validate a cell that it must have an 8-digit number put in it---no
shorter, no longer. No matter how I validate the cell it won't work unless I
select "text length". This is not to be text! It's supposed to be an
8-digit number! What gives? How does one validate this cell to restrict it
to just that? How can something so simple be so contrary?