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

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
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,789
Messages
6,121,605
Members
449,038
Latest member
Arbind kumar

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