G
Guest
Hi,
The worksheet I'm working on now has been pulled together from a number of
different sources (each with their own issues) into what is supposed to be a
comprehensive mailing list.
I wrote the statement below to try to deal with some of that inconsistency
in the Zip Code field -- some entries have five digits, some nine, while
others are either incomplete or entered as text. I formatted the column so
with the "Special" Zip format, but I need to account for leading zeroes,
and/or truncated (5-digit) Zips.
For the most part this formula works, but for some reason, I'm getting
leading zeroes appended to the text entries (CANADA/FOREIGN) in addition to
the numeric ones. Does anyone know why, and/or have a suggestion on how to
adapt this formula to do what I'd like it to do? Any and all assistance
would be greatly appreciated. Thanks.
Formula is as follows:
=IF(LEN(TRIM(CLEAN(K150)))=0,"",(IF(LEN(TRIM(CLEAN(K150)))=5,TRIM(CLEAN(K150))&"0000",IF(AND(9>(LEN(TRIM(CLEAN(K150))))>5,(OR(TRIM(CLEAN(K150))<>"CANADA",TRIM(CLEAN(K150))<>"FOREIGN"))),(REPT("0",(9-(LEN(TRIM(CLEAN(K150))))))&TRIM(CLEAN(K150))),TRIM(CLEAN(K150))))))
The worksheet I'm working on now has been pulled together from a number of
different sources (each with their own issues) into what is supposed to be a
comprehensive mailing list.
I wrote the statement below to try to deal with some of that inconsistency
in the Zip Code field -- some entries have five digits, some nine, while
others are either incomplete or entered as text. I formatted the column so
with the "Special" Zip format, but I need to account for leading zeroes,
and/or truncated (5-digit) Zips.
For the most part this formula works, but for some reason, I'm getting
leading zeroes appended to the text entries (CANADA/FOREIGN) in addition to
the numeric ones. Does anyone know why, and/or have a suggestion on how to
adapt this formula to do what I'd like it to do? Any and all assistance
would be greatly appreciated. Thanks.
Formula is as follows:
=IF(LEN(TRIM(CLEAN(K150)))=0,"",(IF(LEN(TRIM(CLEAN(K150)))=5,TRIM(CLEAN(K150))&"0000",IF(AND(9>(LEN(TRIM(CLEAN(K150))))>5,(OR(TRIM(CLEAN(K150))<>"CANADA",TRIM(CLEAN(K150))<>"FOREIGN"))),(REPT("0",(9-(LEN(TRIM(CLEAN(K150))))))&TRIM(CLEAN(K150))),TRIM(CLEAN(K150))))))