Value if criteria met

J

jh3016

I have a simple question, I believe.

I would like if H2 contains "Grapes", then enter "Grapes" in J2. If H2
contains "Oranges", then enter "Oranges in J2. If H2 does not contain Grapes
or Oranges, enter "Neither" in J2.

Can someone give me the formula for this?

Thanks in advance.
 
B

Bob Phillips

=IF(AND(H2<>"Graapes",H2<>"Oranges"),"Neither",H2)

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
D

Domenic

Try...

=IF(H2="Grapes","Grapes",IF(H2="Oranges","Orange","Neither"))

Hope this helps!
 
B

Bob Phillips

Would help if I could spell

=IF(AND(H2<>"Grapes",H2<>"Oranges"),"Neither",H2)


--

HTH

RP
(remove nothere from the email address if mailing direct)
 
J

jh3016

The formula works if H2 has "Grapes" or "Oranges" exactly. What I need is if
it CONTAINS "Grapes" or "Oranges".

Thanks again.
 
D

Domenic

Try the following instead...

=IF(OR(ISNUMBER(SEARCH({"Grapes","Oranges"},H2))),H2,"Neither")

Hope this helps!
 
D

Domenic

Sorry, make that...

=IF(ISNUMBER(SEARCH("Grapes",H2)),"Grapes",IF(ISNUMBER(SEARCH("Oranges",H
2)),"Oranges","Neither"))

Hope this helps!
 
J

jh3016

I get an error when I run this.

Domenic said:
Sorry, make that...

=IF(ISNUMBER(SEARCH("Grapes",H2)),"Grapes",IF(ISNUMBER(SEARCH("Oranges",H
2)),"Oranges","Neither"))

Hope this helps!
 
D

Domenic

If you copied and pasted the formula into your spreadsheet, make sure a
line break hasn't been added.

Does this help?
 
Top