Thread: Data Validation
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Robert_L_Ross Robert_L_Ross is offline
external usenet poster
 
Posts: 35
Default Data Validation

I'm having some difficulty on my data validation...

I need to validate that a number entered into a cell is:
9 characters wide
9 numbers (123456789, 012345678, etc.)
OR
Starts with an E and has 8 numbers after it (E12345678, E01234567, etc.)

Here's my validation formula:
=OR(AND(TYPE(A2)=2,LEFT(A2,1)="e",TYPE(RIGHT(A2,8) =1),LEN(A2)=9),AND(TYPE(A2)=1,LEN(A2)=7,LEN(A2)<= 9))

Now, from what I've read here on the board, this should be working if all of
these are true:
TYPE(A2)=2 'cell is text
LEFT(A2,1)="e" 'starts with an e
TYPE(RIGHT(A2,8)=1) 'ends in 0 numbers
LEN(A2)=9 'total length is 9 characters
OR
TYPE(A2)=1 'entire value is a number
LEN(A2)=7 'cell has at least 7 digits
LEN(A2)<=9 'cell has no more than 9 digits
'these last two lines are for SSN's that can begin with 00. There should be
no SSN's that start with 000.

For some reason, I can enter e1a345678 and it takes that value, not picking
up that while it starts with an e, it doesn't have 8 numbers following it.
It DOES however pick up a12345678 as an error since it doesn't start with an
e.

I did some troubleshooting...putting the right 8 characters of a2 in a cell
(=RIGHT(A2,8)) and when I try to 'type' that cell, it comes back as text
instead of numbers, even though it contains '12345678'. Any idea why this is?

THX guys!