Re: Unexpected Result with "If" Logic/Conditional Statement
- From: "Bill Ridgeway" <info@xxxxxxxxxxxxxxxxxxx>
- Date: Tue, 3 Jul 2007 18:56:04 +0100
"A Need to Excel" <A Need to Excel@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message news:0CC30777-A926-4EDB-996A-8945B8108E1D@xxxxxxxxxxxxxxxx
Hi,
The work*** 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))))))
I'm not going to try to analyse that one. A solution I've found to work
with enigmatic formula is to break out each of the IF statements into
separate lines (several if an AND or OR is involved) and, with test data,
check the actual outcome with the expected outcome. This is sometimes the
way I construct complicated formula.
Hope this helps!
Bill Ridgeway
Computer Solutions
.
- Follow-Ups:
- Re: Unexpected Result with "If" Logic/Conditional Statement
- From: joeu2004
- Re: Unexpected Result with "If" Logic/Conditional Statement
- Prev by Date: Re: STILL Having VBA Problems!!!!!!!
- Next by Date: Re: Hyperlink files same folder only?
- Previous by thread: Re: STILL Having VBA Problems!!!!!!!
- Next by thread: Re: Unexpected Result with "If" Logic/Conditional Statement
- Index(es):
Loading