Nested If and Or? Function

virago_midget

New Member
Joined
Jun 12, 2011
Messages
2
Hi ya

I'm trying to set a cell to a value depending on several values in another cell.

The cell will contain D,M,P,U or F.

If it contains D then the answer needs to be 80, or if it contains M then the answer needs to be 70 if it contains P then answer is 50, if it's U then it's 10, if F it's 0

I did get it to work with a lookup, but wanted to try doing an If statement.

Any ideas?

Many thanks... first time posting here
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Hi ya

I'm trying to set a cell to a value depending on several values in another cell.

The cell will contain D,M,P,U or F.

If it contains D then the answer needs to be 80, or if it contains M then the answer needs to be 70 if it contains P then answer is 50, if it's U then it's 10, if F it's 0

I did get it to work with a lookup, but wanted to try doing an If statement.

Any ideas?

Many thanks... first time posting here
Like this...

=IF(A1="F",0,IF(A1="U",10,IF(A1="P",50,IF(A1="M",70,IF(A1="D",80,"")))))
 
Upvote 0
Hi ya

I'm trying to set a cell to a value depending on several values in another cell.

The cell will contain D,M,P,U or F.

If it contains D then the answer needs to be 80, or if it contains M then the answer needs to be 70 if it contains P then answer is 50, if it's U then it's 10, if F it's 0

I did get it to work with a lookup, but wanted to try doing an If statement.

Any ideas?

Many thanks... first time posting here

The best practice is a look up formula...

=VLOOKUP(A2,{"D",80;"M",70;"P",50;"U",10;"F",0},2,0)

Otherwise, you need a chain of IFs, hopefully correctly itemized...
Code:
=IF(A2="D",
    80,
    IF(A2="M",
      70,
      IF(A2="P",
        50,
        IF(A2="U",
          10,
          IF(A2="F",
            0,
            "")))))
 
Upvote 0
Fantastic! I now realised why I couldn't get the IF to work on it's own, and thanks so much for the Lookup as well.

My grades calculator works brilliant.

Good job I only teach Excel to A level standard, otherwise I'd be stuck!
 
Upvote 0
Fantastic! I now realised why I couldn't get the IF to work on it's own, and thanks so much for the Lookup as well.

My grades calculator works brilliant.

Good job I only teach Excel to A level standard, otherwise I'd be stuck!

You are welcome. Thanks for providing feedback.
 
Upvote 0
Fantastic! I now realised why I couldn't get the IF to work on it's own, and thanks so much for the Lookup as well.

My grades calculator works brilliant.

Good job I only teach Excel to A level standard, otherwise I'd be stuck!
You're welcome. Thanks for the feedback! :cool:
 
Upvote 0

Forum statistics

Threads
1,224,578
Messages
6,179,654
Members
452,934
Latest member
mm1t1

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