simplify and if formula

d0wnt0wn

Well-known Member
Joined
Oct 28, 2002
Messages
771
hey guys,

I am wondering if there is a more simple way to do this

=IF(AND(B3=8,C3="B"),4,IF(AND(B3=9,C3="B"),7,IF(AND(B3=7,C3="A"),0,IF(AND(B3=8,C3="A"),2,IF(AND(B3=9,C3="A"),5,IF(AND(B3=7,C3="B"),2,IF(AND(B3=7,C3="C"),4,IF(AND(B3=8,C3="C"),6,IF(AND(B3=9,C3="c"),9,IF(AND(B3=7,C3="B"),2,IF(AND(B3=7,C3="P"),-2,IF(AND(B3=8,C3="P"),0,IF(AND(B3=9,C3="P"),3,"")))))))))))))

essentially its looking for 2 criteria to give me a value. For example if cell B3=8 and C3=A the result is 2..... 8 is woth 2 points and A is worth 0... but what i really want is to make it so i can easily add more criteria to get my result and be able to change the value of each of those criteria without having to change the whole formula each time
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
How about
=IFERROR(IF(C3="A",CHOOSE(B3-6,0,2,5),IF(C3="B",CHOOSE(B3-6,2,4,7),IF(C3="C",CHOOSE(B3-6,4,6,9),IF(C3="P",CHOOSE(B3-6,-2,0,3),"")))),"")
 
Upvote 0
Would be best with a lookup table, (formula in D3), I've also included a formula in D4 that works without the table, but doing it that way is just bad practice.
The List.xlsx
BCDEFGHIJ
2ABCP
38B47024-2
49C982460
595793
Sheet1
Cell Formulas
RangeFormula
D3D3=INDEX($G$3:$J$5,MATCH(B3,$F$3:$F$5,0),MATCH(C3,$G$2:$J$2,0))
D4D4=IFERROR(INDEX({0,2,4,-2;2,4,6,0;5,7,9,3},MATCH(B4,{7,8,9},0),MATCH(C4,{"A","B","C","P"},0)),"")
 
Upvote 0
Another option, using LOOKUP:

=IF(COUNTA(B3:C3)=2,LOOKUP(B3&C3,{"7A","7B","7C","7P","8A","8B","8C","8P","9A","9B","9C","9P"},{0,2,4,-2,2,4,6,0,5,7,9,3}),"")
 
Upvote 0
Another option
=CHOOSE(B3-6,0,2,5)+SWITCH(C3,"A",0,"B",2,"C",4,"P",-2)
 
  • Like
Reactions: Z51
Upvote 0
Another option
=CHOOSE(B3-6,0,2,5)+SWITCH(C3,"A",0,"B",2,"C",4,"P",-2)
fluff could you please explain this formula to me... it works great but i have never seen choose and switch before... if i want to add more conditions do i just add another +switch?
 
Upvote 0
Another one based on Fluff's idea from post 5

=CHOOSE(B3-6,0,2,5)+(SEARCH(C3,"PABC")-2)*2

Shorter formulas like this are not always better though, especially if the result values change in a way that you might not be able to follow the original pattern.
 
Upvote 0
For choose
Switch

To add more criteria for C3 just add them to the switch formula.
 
Upvote 0
fluff could you please explain this formula to me... it works great but i have never seen choose and switch before... if i want to add more conditions do i just add another +switch?
i dont know what the B3-6 part means
 
Upvote 0

Forum statistics

Threads
1,215,461
Messages
6,124,952
Members
449,198
Latest member
MhammadishaqKhan

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