Link to home
Start Free TrialLog in
Avatar of 1r3o2n8
1r3o2n8Flag for United States of America

asked on

zip code validation

In a cell, I have zip+4 format, but this does not  prevent erroneous entries.  I need code to insure 5 numbers, hyphen, four numbers, ie #####-####.  Other charfacters and too many numbers or not enough numbers should bring up an error with a retry or cancel.   Would the zip+4 formatting still be required?   Please be thorough in your answer.  Thanks in advance for your kind help!  rgds/ron
Avatar of zorvek (Kevin Jones)
zorvek (Kevin Jones)
Flag of United States of America image

Use this validation rule:

=AND(SEARCH("?????-????",A1)=1,LEN(A1)=10,ISNUMBER(VALUE(SUBSTITUTE(A1,"-",""))))

Kevin
To use a validation rule, select the cell to be validated, navigate to the Data tab, click Data Validation to bring up the Data Validation dialog. Select Custom and enter the formula above changing A1 to the selected cell. Click OK.

Kevin
Avatar of 1r3o2n8

ASKER

It doesn't seem to work for me.  Go to the area of J20 in sht Customer1 and try it for me.  THX
RETAXES---Copy1-040211sendOnly.xlsm
ASKER CERTIFIED SOLUTION
Avatar of zorvek (Kevin Jones)
zorvek (Kevin Jones)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of 1r3o2n8

ASKER

You're wonderful!  Thanks alot.  rgds/ron