Nested IF statement: Breaking the 7 output limit?

Carl B

Board Regular
Joined
Feb 15, 2002
Messages
65
I was surfing the web and ran into a little formula that goes beyond the 7 outputs of an IF statement.
Whenever I had more choices then the 7 output limit, I usually parsed it out over a couple cells to get my results.
Whereas this person was able to get 27 different outputs to thier IF statement in a single cell.
How it was shown was by outputting a number associated with a letter the user types in, e.g. A = 1, B=2 etc..

What I was wondering is if anyone here would like to take on that challenge?
Can we see how many different ways this can be done with an IF statement?

I will post the IF statement if anyone is curious.
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
I like those work arounds, gets me thinking about where I have used other things where those would diffenitely tidy up the ws.

This was what I found:

=IF(OR(B2="a",B2="b",B2="c",B2="d",B2="e",B2="f"),IF(B2="a",1,IF(B2="b",2,IF(B2="c",3,IF(B2="d",4,IF(B2="e",5,6))))),IF(OR(B2="g",B2="h",B2="i",B2="j",B2="k",B2="l"),IF(B2="g",7,IF(B2="h",8,IF(B2="i",9,IF(B2="j",10,IF(B2="k",11,12))))),IF(OR(B2="m",B2="n",B2="o",B2="p",B2="q",B2="r"),IF(B2="m",13,IF(B2="n",14,IF(B2="o",15,IF(B2="p",16,IF(B2="q",17,18))))),IF(OR(B2="s",B2="t",B2="u",B2="v",B2="w"),IF(B2="s",19,IF(B2="t",20,IF(B2="u",21,IF(B2="v",22,23)))),IF(B2="x",24,IF(B2="y",25,IF(B2="z",26,"error - type a letter")))))))
 
...can be shortened to.

=CODE(B2)-96


Or if you do not actually have those letters; Use VLOOKUP.

Or maybe:

=MATCH(B2,{"a";"b";"c";"d";"e";"f";"g";"h";"i";"j";"k";"l";"m";"n";"o";"p";"q";"r";"s";"t";"u";"v";"w";"x";"y";"z"},0)
 

Forum statistics

Threads
1,222,759
Messages
6,168,049
Members
452,160
Latest member
Bekerinik

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top