Home » excel » Too many if or nested loop in excel

Too many if or nested loop in excel

Posted by: admin April 23, 2020 Leave a comment


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



How to&Answers:

I think table lookup is much simpler than a bunch of ifs:




Even more simple if your conditions and results are continuous ranges


There is a hard limit of 7 nested if in Excel.

Here is a trick to increase this limitation.


The following array formula may help:


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.