Hi there.
How would my if statement look like if I my logical test can be more than 1
value?
For example, if cell A1 = "apple" or "oranges", then return 1, else return
2. How can I show the apple or oranges logical test in equation form?
Thank you!
Rick Rothstein (MVP - VB) - 28 May 2008 21:14 GMT
Try this...
=IF(OR(A1={"apple","orange"}),1,2)
Note: I left both of these singular even though you made 'apple' singular
and 'oranges' plural. If you need that mixture, just add the 's' onto the
end of 'orange'. The key is, put all the text you want the cell to match
inside the curly braces, quoted and comma delimited.
Rick
> Hi there.
>
[quoted text clipped - 6 lines]
>
> Thank you!
Storm - 28 May 2008 21:33 GMT
Great! Not having to specify the reference cell "A1" at each instance is
efficient. Thanks for your time!
> Try this...
>
[quoted text clipped - 17 lines]
> >
> > Thank you!
Luke M - 28 May 2008 21:19 GMT
Use the OR function such as
=If(OR(A1="apple",A1="oranges"),1,2)

Signature
Best Regards,
Luke M
> Hi there.
>
[quoted text clipped - 5 lines]
>
> Thank you!
Storm - 28 May 2008 21:31 GMT
Thank you Luke. I was hoping there was I way I didn't have to specify the
"A1" reference cell at each instance...but hey, it works! Thanks for your
time.
> Use the OR function such as
> =If(OR(A1="apple",A1="oranges"),1,2)
[quoted text clipped - 8 lines]
> >
> > Thank you!
T. Valko - 28 May 2008 21:26 GMT
Try one of these:
=IF(OR(A1="apple",A1="orange"),1,2)
=IF(OR(A1={"apple","orange"}),1,2)
C1 = apple
C2 = orange
=IF(OR(A1=C1,A1=C2),1,2)
As an array formula** :
=IF(OR(A1=C1:C2),1,2)
** array formulas need to be entered using the key combination of
CTRL,SHIFT,ENTER (not just ENTER)

Signature
Biff
Microsoft Excel MVP
> Hi there.
>
[quoted text clipped - 6 lines]
>
> Thank you!
Storm - 28 May 2008 21:50 GMT
This is great! Thanks Biff!
> Try one of these:
>
[quoted text clipped - 24 lines]
> >
> > Thank you!
Storm - 28 May 2008 22:04 GMT
Hi Bill...
What if...using the array method, I do have a list but I only want a select
few on that list? For example: C1 = apple; C2 = oranges; C3 = grapes. I
want my logical test to match either apple or grape, can I use this method?
I tried to edit the formula to show instead of =IF(OR(A1=C1:C2),1,2) I did
=IF(OR(A1=C1,C3),1,2)For some reason, even if A1 = C3, it still returned 2.
(note: when A1 = C1, it returned 1).
Thanks
> Try one of these:
>
[quoted text clipped - 24 lines]
> >
> > Thank you!
T. Valko - 28 May 2008 22:32 GMT
>can I use this method?
Not without making it overly complicated!
Array entered:
=IF(OR(A1=T(OFFSET(C1:C3,{0,2},,))),1,2)
D1 = 0
D2 = 2
=IF(OR(A1=T(OFFSET(C1:C3,D1:D2,,))),1,2)
So, for practical purposes, I would not use these!

Signature
Biff
Microsoft Excel MVP
> Hi Bill...
>
[quoted text clipped - 40 lines]
>> >
>> > Thank you!
Storm - 28 May 2008 22:38 GMT
Gocha! Thanks again Biff.
> >can I use this method?
>
[quoted text clipped - 55 lines]
> >> >
> >> > Thank you!
T. Valko - 28 May 2008 22:53 GMT
You're welcome!

Signature
Biff
Microsoft Excel MVP
> Gocha! Thanks again Biff.
>
[quoted text clipped - 61 lines]
>> >> >
>> >> > Thank you!
Aladin Akyurek - 28 May 2008 21:32 GMT
=2-OR(A1="Apple",A1="Oranges")
> Hi there.
>
[quoted text clipped - 5 lines]
>
> Thank you!
Storm - 28 May 2008 21:49 GMT
Thanks Aladin!
> =2-OR(A1="Apple",A1="Oranges")
>
[quoted text clipped - 7 lines]
> >
> > Thank you!
ASA - 29 May 2008 01:38 GMT
I would be tempted to use a vlookup, create a table with your fruit in the
first column and a number in the second. then use formula
=vlookup (a1, fruittable, 2,0)
> Hi there.
>
[quoted text clipped - 5 lines]
>
> Thank you!
Teethless mama - 29 May 2008 03:41 GMT
=NOT(OR(A1={"apple","oranges"}))+1
> Hi there.
>
[quoted text clipped - 5 lines]
>
> Thank you!