LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,059
Default Unexpected Result with "If" Logic/Conditional Statement

On Jul 3, 9:52 am, A Need to Excel
<A Need to wrote:
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.
[....]
Formula is as follows:
=IF(LEN(TRIM(CLEAN(K150)))=0,"",(IF(LEN(TRIM(CLEAN (K150)))=5,TRIM
(CLEAN(K15*0))&"0000",IF(AND(9(LEN(TRIM(CLEAN(K15 0))))5,(OR(TRIM
(CLEAN(K150))<"CANA*DA",TRIM(CLEAN(K150))<"FOREI GN"))),
(REPT("0",(9-(LEN(TRIM(CLEAN(K150))))))*&TRIM(CLEAN(K150))),
TRIM(CLEAN(K150))))))


I am not taking the time to parse and understand the above, and the
following might not address your specific question. But I do notice
one glaring syntax error that will be troublesome at least in __some__
cases. You wrote:

AND(9(LEN(TRIM(CLEAN(K150))))5,
(OR(TRIM(CLEAN(K150))<"CANA*DA",
TRIM(CLEAN(K150))<"FOREIGN")))

"9LEN(...)5" does not do what you intended. I think you want:

AND(9LEN(...), LEN(...)5, OR(TRIM(...)<"CANADA",
TRIM(...)<"FOREIGN")

PS: I don't know why you bother to check the length. It seems
sufficient just to compare with the expected text, "CANADA" and
"FOREIGN".

FYI, I think it would be easier for you (and everyone else) to read
and maintain if you eliminated unnecessary parentheses. For example,

(REPT("0",(9-(LEN(TRIM(CLEAN(K150))))))&TRIM(CLEAN(K150)))

can be written more simply as:

REPT("0", 9-LEN(TRIM(CLEAN(K150)))) & TRIM(CLEAN(K150))

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unexpected Result with "If" Logic/Conditional Statement Bill Ridgeway Excel Discussion (Misc queries) 1 July 3rd 07 07:07 PM
Can I include a "validation drop down" in a conditional statement? JanW Excel Worksheet Functions 1 June 5th 07 08:50 PM
"An unexpected error has occured" Froshawn Excel Discussion (Misc queries) 0 April 16th 07 07:32 AM
embedding "ISERROR" function into an "IF" statement [email protected] Excel Worksheet Functions 8 January 4th 07 12:01 AM
"Reading"the logic behind too-long command statements Alex Excel Worksheet Functions 2 August 29th 06 08:12 PM


All times are GMT +1. The time now is 05:19 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"