IF Formula - Contains X and Y, also Does Not Contain U,V,W

JExcel123

New Member
Joined
Oct 4, 2017
Messages
5
Hello! I'm trying to write two different formulas that show the following:

Typing in Cell B1...If Cell A1 contains "Apple" AND "Orange", but also DOES NOT contain "Banana" OR "Grape" OR "Pear", then return the value in cell D1, otherwise, return a blank.

Typing in Cell C1...If Cell A1 contains "Apple" AND "Orange", and ALSO contains "Banana" OR "Grape" OR "Pear", then return the value in cell D1, otherwise, return a blank.

I came up with this so far for the second set of criteria, but Excel won't accept it...not sure if I'm even on the right track...


=IF(AND(ISNUMBER(SEARCH("Apple",A1)),ISNUMBER(SEARCH("Orange",A1))),IF(OR(ISNUMBER(SEARCH("Banana",A1)),ISNUMBER(SEARCH("Grape",A1)),ISNUMBER(SEARCH("Pear",A1)))),D1,"")
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Welcome to the board. It looks like your false outcome for the whole thing is in the wrong spot:

This:
=IF(AND(ISNUMBER(SEARCH("Apple",A1)),ISNUMBER(SEARCH("Orange",A1))),IF(OR(ISNUMBER(SEARCH("Banana",A1)),ISNUMBER(SEARCH("Grape",A1)),ISNUMBER(SEARCH("Pear",A1)))),D1,"")
To this:
=IF(AND(ISNUMBER(SEARCH("Apple",A1)),ISNUMBER(SEARCH("Orange",A1))),IF(OR(ISNUMBER(SEARCH("Banana",A1)),ISNUMBER(SEARCH("Grape",A1)),ISNUMBER(SEARCH("Pear",A1))),D1,""))
 
Upvote 0
Yay! That worked!!! The only issue is it either returns the value in D1 or it returns FALSE. How can I make it return blank rather than FALSE?
 
Upvote 0
D1 is a number :)

1.

=IF((SUM(ISNUMBER(SEARCH(" "&{"apple","orange"}," "&A1))+0)=2)*(1-ISNUMBER(LOOKUP(9.99999999999999E+307,SEARCH(" "&{"banana","grape","pear"}," "&A1)))),D1,"")

2.

=IF((SUM(ISNUMBER(SEARCH(" "&{"apple","orange"}," "&A1))+0)=2)*ISNUMBER(LOOKUP(9.99999999999999E+307,SEARCH(" "&{"banana","grape","pear"}," "&A1))),D1,"")
 
Upvote 0
Yay! That worked!!! The only issue is it either returns the value in D1 or it returns FALSE. How can I make it return blank rather than FALSE?

Then this:

=IF(AND(ISNUMBER(SEARCH("Apple",A1)),ISNUMBER(SEARCH("Orange",A1))),IF(OR(ISNUMBER(SEARCH("Banana",A1)),ISNUMBER(SEARCH("Grape",A1)),ISNUMBER(SEARCH("Pear",A1))),D1,""),"")
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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