How to do an IF statement and an AND statement in same cell with different outcomes

Rmayfield

New Member
Joined
Feb 19, 2021
Messages
13
Office Version
  1. 2013
Platform
  1. Windows
Trying to figure out how to do an IF statement and an AND statement in the same cell with different outcomes

Cell A1 has an X in it

Cell A2 has an X in it

Cell A3 has an X in it
Cell A4 has an X in it
Cell A5 has my formula

I want the formula to say if cell A1 and A2 have an X (A3 and A4 are blank), then return "Apple" in A5. If A1 and A3 have an X (A2 and A4 are blank), then return "Orange" in A5. If A1 and A4 have an X (A2 and A3 are blank), then return "Pear" in A5. If A1 is empty, then return blank in A5.
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Will those cells only have an X or be blank?
 
Upvote 0
=IF ( A1 = "", "", IF( AND ( A1 ="X", A2 ="X", A3 ="" , A4 ="" ) , "Apple", IF( AND ( A1 ="X", A2 ="", A3 ="X" , A4 ="" ) , "ORANGE", IF( AND ( A1 ="X", A2 ="", A3 ="" , A4 ="X" ) , "Pear" ))))

But that is how you asked, with the Logic in FULL
 
Upvote 0
In that case try etaf's solution, although it can be slimmed down slightly like
Excel Formula:
=IF(A1="","",IF(AND(A2="X",A3="",A4=""),"Apple",IF(AND(A2="",A3="X",A4=""),"ORANGE",IF(AND(A2="",A3="",A4="X"),"Pear",""))))
 
Upvote 0
Solution
In that case try etaf's solution, although it can be slimmed down slightly like
Excel Formula:
=IF(A1="","",IF(AND(A2="X",A3="",A4=""),"Apple",IF(AND(A2="",A3="X",A4=""),"ORANGE",IF(AND(A2="",A3="",A4="X"),"Pear",""))))
That did it! Thank you, thank you!
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,644
Messages
6,120,709
Members
448,983
Latest member
Joaquim_Baptista

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