I have a code that has way too many nested statements
Basically I have 1 cell to be compared with 100 cells and those 100 cells have their own value, and Excel only have max 64 if loops.
Any suggestions?
A=B =>> X=B1
A=C =>> X=C1
A=D =>> X=D1
A=E =>> X=E1
IF(L2=S2,T2,IF(L3=S3,T3,IF(L4=S4,T4,IF(L5=S5,T5,IF(L6=S6,T6,IF(L7=S7,T7,IF(L8=S8,T8,IF(L9=S9,T9,IF(L10=S10,T10,IF(L11=S11,T11))))))))))
Thanks!
I think table lookup is much simpler than a bunch of ifs:
=HLOOKUP(Value,{"Cond1","Cond2","Cond3";"Res1","Res2","Res3"},2,FALSE)
or
=VLOOKUP(Value,{"Cond1","Res1";"Cond2","Res2";"Cond3","Res3"},2,FALSE)
Even more simple if your conditions and results are continuous ranges
Answer:
There is a hard limit of 7 nested if
in Excel.
Here is a trick to increase this limitation.
Answer:
The following array formula may help:
={INDEX(A1:H1;1;MIN((IF(L3:R3=S3:Y3;COLUMN(B1:H1);""))))}
L3:R3
Data array 1 being compared
S3:Y3
Data array 2 being compared
B1:H1
Corresponding values for data arrays
INDEX
will find the value from interection of row 1 and the column corresponding to the first match found. The sizes of arrays should match, otherwise the formula will give #N/A
.
The formula is inserted with Shift-Ctrl-Enter, curled brackets are inserted by Excel, not by a user.
Tags: excelexcel, oop