ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Nested IF error (https://www.excelbanter.com/excel-discussion-misc-queries/136424-nested-if-error.html)

KD

Nested IF error
 
Hi,
Any help in the error below would be greatly appreciated.

=if(L2="I",if(L2="R","B",IF(L2="F","Ro",if(L2="SCA ","Ri",if(or(S2="IA",N2="GBS"),"GN",if(AND(L2="HC" ,or(N2="Fi",N2="In",N2="XC")),"OM",if(OR(N2="Ex",S 2<"IA"),N2="COS",N2="CO",S2="L"),"D","W")))))))

Thanks in advance.
KD

KD

Nested IF error
 
Mike/Greg/Boni,

Thanks so much for your time. After viewing your responses, I played with
the formula a few more times and got the result/s I was looking for, here is
the one giving correct result.

=IF(H2="I","W",IF(H2="R","B",IF(H2="F","Ro",IF(H2= "SCA","Ri",IF(OR(N2="IA",I2="GBS"),"GN",IF(AND(H2= "HC",OR(I2="Fi",I2="In",I2="XC")),"OM",IF(OR(I2="E x",N2<"IA",I2="COS",I2="CO",N2="L"),"D",FALSE)))) )))

Thanks again for looking into my problem.
KD

"BoniM" wrote:

It would help if you would let us know what you're trying to do.
What you have here are a couple of problems, first you're testing L2 for
"I", but if that's true, then you're testing for "R"? it can't be both. I
think you left out a value if true here.
Your next problem is with this:
if(OR(N2="Ex",S2<"IA"),N2="COS",N2="CO",S2="L")," D","W")
specificallly this part:
OR(N2="Ex",S2<"IA"),N2="COS",N2="CO",S2="L")
what were you intending to test here? If it could be anyone of those and be
true then you have an extra ) after "IA".
With those two corrections you would get a workable formula, but we need
more info if it isn't what you wanted:
=IF(L2="I","True Value
Here",IF(L2="R","B",IF(L2="F","Ro",IF(L2="SCA","Ri ",IF(OR(S2="IA",N2="GBS"),"GN",IF(AND(L2="HC",OR(N 2="Fi",N2="In",N2="XC")),"OM",IF(OR(N2="Ex",S2<"I A",N2="COS",N2="CO",S2="L"),"D","W")))))))


"kd" wrote:

Hi,
Any help in the error below would be greatly appreciated.

=if(L2="I",if(L2="R","B",IF(L2="F","Ro",if(L2="SCA ","Ri",if(or(S2="IA",N2="GBS"),"GN",if(AND(L2="HC" ,or(N2="Fi",N2="In",N2="XC")),"OM",if(OR(N2="Ex",S 2<"IA"),N2="COS",N2="CO",S2="L"),"D","W")))))))

Thanks in advance.
KD


Greg Wilson

Nested IF error
 
With credit to bj in his/her response to your post in the worksheet functions
ng, if you remove the ")" following the "IA" it becomes structurally correct
and looks sensible to me. But I suspect this is still not what you intended.

We don't know how your worksheet is layed out and what you are trying to
achieve. You need to specify it. It's not just a simple "fix what's broken"
issue. It's a design flaw and there's more than one way to redesign it.

Note that your first (parent) IF function has only two arguments. This is
still syntactically correct because the third is optional. The formula in
this case will return FALSE by default.

FWIW, pseudo VBA code that translates the syntactically correct part of your
formula follows. Perhaps this logic structure or something along this line
could be used to spell out what you want:

If L2 = "I" Then
If L2 = "R" Then
Return "B"
ElseIf L2 = "F" Then
Return "Ro"
ElseIf L2 = "SCA" Then
Return "Ri"
ElseIf Or(S2 = "IA", N2 = "GBS") Then
Return "GN"
ElseIf AND(L2 = "HC", OR(N2 = "Fi", N2 = "In", N2 = "XC") Then
Return "OM"
<<<<<<< syntactically incorrect beyond here
End IF
End If

Regards,
Greg





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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com