View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Harlan Grove[_2_] Harlan Grove[_2_] is offline
external usenet poster
 
Posts: 1,231
Default Better way than Nesting, or other solutions

"Dane" wrote...
I have a formula that nests... 220 times. How do I get it in there?? It's
for calculating different numbers when a different choice from a drop-down
list is picked.

Here is the formula:

=IF(AND(F3="Fighter",C2=1),
T("+1"),


And what do you believe the benefits of T("+1") are over just "+1"?

IF(AND(F3="Fighter",C2=2),
T("+2"),
IF(AND(F3="Fighter",C2=3),
T("+3"),
IF(AND(F3="Fighter",C2=4),
T("+3"),


If both C2=3 and C2=4 result in "+3", why not use just one IF, i.e.,

IF(AND(F3="Fighter",OR(C2={3,4}),"+3",...

?

This is all entirely unnecessary. Use lookup tables. Create a table with top
row containing the different F3 values and the rows below in each column
containing the values corresponding to the C2 values, e.g.,


Fighter__Spell User__Illusionist__Rogue __ . . .
___1_________1____________1__________1____ . . .
___2_________1____________1__________1____ . . .
___3_________1____________1__________2____ . . .
___3_________1____________1__________2____ . . .
___4_________2____________2__________3____ . . .
___5_________2____________2__________3____ . . .
___6_________2____________2__________4____ . . .
___6_________2____________2__________4____ . . .
:
:


Name this table TBL. Then use a formula like

=IF(AND(COUNTIF(INDEX(TBL,1,0),F3),C2=1,C2<=20,C2 =INT(C2)),
"+"&HLOOKUP(F3,TBL,C2+1,0),"invalid")