IF function

georgie23

New Member
Joined
May 1, 2013
Messages
26
Hi guys,

I would like to ask for your help with an If function.

What I would like to do can be seen below:

IF A>0 and B>0 see "X"
IF A>0 and B=0 see "W"
IF A=0 and B>0 see "Z"
If A=0 and B=0 see "Y"

From
To
Result
16
18
X
170W
0
19
Z
0
0
Y

<tbody>
</tbody>


Thank you for the help in advance

Greg
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
georgie23

Welcome to the MrExcel forum.

Something like this?


Excel 2007
ABC
1FromToResult
21618X
3170W
4019Z
500Y
Sheet1
Cell Formulas
RangeFormula
C2=IF(AND(A2=0,B2=0),"Y",IF(AND(A2=0,B2>0),"Z",IF(AND(A2>0,B2=0),"W",IF(AND(A2>0,B2>0),"X",""))))


The formula in cell C1 copied down:
=IF(AND(A2=0,B2=0),"Y",IF(AND(A2=0,B2>0),"Z",IF(AND(A2>0,B2=0),"W",IF(AND(A2>0,B2>0),"X",""))))
 
Upvote 0
Similar to hiker95's, but a bit shorter...
=IF(A2>0,IF(B2>0,"X","W"),IF(B2>0,"Z","Y"))
 
Upvote 0
Or perhaps

=IF(A1*B1>0,"X",IF(B1=0,IF(A1>0,"W","Y"),"Z"))

This relies on there never being any negative values in your data.
 
Upvote 0
Assuming no negatives ..

njimack's formula could be condensed to

=IF(A2,IF(B2,"X","W"),IF(B2,"Z","Y"))


.. or for a longer but different approach

=LOOKUP((SIGN(A2)&SIGN(B2))+0,{0,1,10,11},{"Y","Z","W","X"})
 
Upvote 0

Excel 2007
ABCDEFGHIJKLM
150
2
3
4
5
6
7.=IF(AND(A1>0,B1>0),"X","")These 4 lines are how I would accomplish your single arguments
8W.=IF(AND(A1>0,B1=0),"W","")
9.=IF(AND(A1=0,B1>0),"Z","")
10.=IF(AND(A1=0,B1=0),"Y","")
11
12W.=IF(AND(A1>0,B1>0),"X",IF(AND(A1>0,B1=0),"W",""))This is how I would put two together
13W.=IF(AND(A1>0,B1>0),"X",IF(AND(A1>0,B1=0),"W",IF(AND(A1=0,B1>0),"Z","")))This is how I put three together.
14You should be able to follow this
15and add your fourth argument
16
17
18
19
20
Sheet1


I hope this helps you Don
 
Upvote 0
Wow, I will have to be quicker around here. when I first looked at your post Georgie there were no replys, by the time I posted my version of an answer your had 5 others.
 
Last edited:
Upvote 0
georgie23,

You are very welcome. Glad we could help.

Thanks for the feedback.

And, come back anytime.
 
Upvote 0

Forum statistics

Threads
1,214,601
Messages
6,120,467
Members
448,965
Latest member
grijken

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