If statement

hayati

Board Regular
Joined
Oct 3, 2005
Messages
118
Hi,

Need some help with an if statement I am working on. Here are the conditions:

1) If A1 = NP then S
2) If A1 = PH and A2 = PD then P
3) If A1 = PH and A2 NOT PD then S
4) If A1 = PD then C

There are only three variables NP, PH,PD

An example:

Column A Column B
NP s
PH p
PD c
PD c
PD c
PH s
NP s
PH p
PD c

Currently I have:

=IF(A8="NP","s",IF(AND(A8="PH",A9="PD"),"p",IF(AND(A8="PH",OR(A9="PH",A9="NP")),"s",IF(A8="PD","c"))))

But I think there must be a better way to do it?

Any thoughts?

Cheers
Matt
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
hayati

IF NP, PH & PD are the only values allowed in A1 then try:
=IF(A1="NP","S",IF(A1="PD","C",IF(A2="PD","P","S")))
 
Upvote 0
Thanks!

Hi gents,

Thanks, I knew there could be a better way of stating that.

Both formulas work like a charm!

Cheers,
Matt
 
Upvote 0

Forum statistics

Threads
1,214,599
Messages
6,120,447
Members
448,966
Latest member
DannyC96

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