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

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
62,215
Office Version
  1. 365
Platform
  1. Windows
Will those cells only have an X or be blank?
 

etaf

Well-known Member
Joined
Oct 24, 2012
Messages
4,865
Office Version
  1. 365
Platform
  1. MacOS
=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
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
62,215
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

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",""))))
 
Solution

Rmayfield

New Member
Joined
Feb 19, 2021
Messages
13
Office Version
  1. 2013
Platform
  1. Windows
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!
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
62,215
Office Version
  1. 365
Platform
  1. Windows
Glad we could help & thanks for the feedback.
 

Forum statistics

Threads
1,140,995
Messages
5,703,619
Members
421,306
Latest member
ambuj Thakur

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
Top