PC Review


Reply
Thread Tools Rate Thread

AND/OR Statements

 
 
jazdwit07@aol.com
Guest
Posts: n/a
 
      3rd Jan 2006
Need help once again.
I am trying to enter an if statement using and/or. what i am trying to
do is find out if G2 has a "yes" and column I2's date is <=1/4/2005
then give me "ok", OR, if
G2 has a "no" and I2's date is <=1/4/2005 then give me "ck".
Is this doable?
thanks.

IF((AND(G2="yes",I2<=date(2005,1,4)),"ok",(IF((OR(G2="no",I2<=date(2005,1,4)),"ck")))

 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      3rd Jan 2006
The words seem different to the formula, but is this what you want

=IF(OR(AND(G2="yes",I2<=DATE(2005,1,4)),OR(G2="no",I2<=DATE(2005,1,4))),"ck"
,"")


--

HTH

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


<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Need help once again.
> I am trying to enter an if statement using and/or. what i am trying to
> do is find out if G2 has a "yes" and column I2's date is <=1/4/2005
> then give me "ok", OR, if
> G2 has a "no" and I2's date is <=1/4/2005 then give me "ck".
> Is this doable?
> thanks.
>
>

IF((AND(G2="yes",I2<=date(2005,1,4)),"ok",(IF((OR(G2="no",I2<=date(2005,1,4)
),"ck")))
>



 
Reply With Quote
 
=?Utf-8?B?am9ldTIwMDRAaG90bWFpbC5jb20=?=
Guest
Posts: n/a
 
      3rd Jan 2006
"(E-Mail Removed)" wrote:
> I am trying to enter an if statement using and/or.
> what i am trying to do is find out if G2 has a "yes"
> and column I2's date is <=1/4/2005 then give me
> "ok", OR, if G2 has a "no" and I2's date is <=1/4/2005
> then give me "ck". Is this doable?
> [....]
> IF((AND(G2="yes",I2<=date(2005,1,4)),"ok",
> (IF((OR(G2="no",I2<=date(2005,1,4)),"ck")))


To match the English description, simply change "OR"
to "AND" -- oh, and change "(AND" to "AND". The
false_value part of the first IF() function is an implicit
"OR". It reads: if "this AND that", then "ok", (or) else
if "this AND that", then "ok".

However, when you have mutually-exclusive conditions
(if G2 can only be "yes" or "no") or when you have a
common condition (I2 <= same date), you can usually
simplify the IF() clauses, often avoiding AND() and OR()
altogether. Also, things will be more readable if you
get rid of redundant parentheses, decide what to do if
neither "ok" nor "ck" condition is true, and always have
all false_values (otherwise, you might see "FASLE").

For example:

a. If G2 can be something other than "yes" and "no"

IF(I2 > DATE(2005,1,4), "",
IF(G2 = "yes", "ok", IF(G2 = "no"), "ck", "")))

b. If G2 can only be "yes" and "no"

IF(I2 > DATE(2005,1,4), "", IF(G2 = "yes", "ok", "ck"))
 
Reply With Quote
 
Max
Guest
Posts: n/a
 
      3rd Jan 2006
Perhaps try also:
=IF(OR(I2={"",0}),"",IF(AND(G2="yes",I2<=DATE(2005,1,4)),"ok",IF(AND(G2="no"
,I2<=DATE(2005,1,4)),"ck","")))

(Presumed you wanted blanks: "" returned as the Value_if_FALSE)

The additional front check on I2: =IF(OR(I2={"",0}),"", ... )
is just a precaution taken to prevent empty cell/zero
from being evaluated as a "valid date" which might give spurious results
--
Rgds
Max
xl 97
---
Singapore, GMT+8
xdemechanik
http://savefile.com/projects/236895
--
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Need help once again.
> I am trying to enter an if statement using and/or. what i am trying to
> do is find out if G2 has a "yes" and column I2's date is <=1/4/2005
> then give me "ok", OR, if
> G2 has a "no" and I2's date is <=1/4/2005 then give me "ck".
> Is this doable?
> thanks.
>
>

IF((AND(G2="yes",I2<=date(2005,1,4)),"ok",(IF((OR(G2="no",I2<=date(2005,1,4)
),"ck")))
>



 
Reply With Quote
 
jazdwit07@aol.com
Guest
Posts: n/a
 
      4th Jan 2006
hmmm....seems to get an error message using that string. by the way,
what do the brackets represent? thanks.

 
Reply With Quote
 
Max
Guest
Posts: n/a
 
      4th Jan 2006
<(E-Mail Removed)> wrote:
> .. seems to get an error message using that string ...


Not sure why you hit the error,
but here's a quick sample with the formula implemented:
http://cjoint.com/?beezJ3PTwp
jazdwit07_gen.xls

> what do the brackets represent?


the curly braces {...} means it's an array

=OR(I2={"",0})
is just a shorter way of writing: =OR(I2="",I2=0)
(both expressions return the same results)
--
Rgds
Max
xl 97
---
Singapore, GMT+8
xdemechanik
http://savefile.com/projects/236895
--


 
Reply With Quote
 
jazdwit07@aol.com
Guest
Posts: n/a
 
      4th Jan 2006
hey, that's a pretty neat trick! thanks for visual.

 
Reply With Quote
 
jazdwit07@aol.com
Guest
Posts: n/a
 
      4th Jan 2006
hey, that's a neat trick! thanks for the visual.

 
Reply With Quote
 
jazdwit07@aol.com
Guest
Posts: n/a
 
      4th Jan 2006
thanks, bob. you're close but i think my explanation was a bit off.
how's this? if (G) = yes, and ( I ) is <=date, then give me Y; and if
(G) = yes and ( I ) is >than date, then give me, CK and finally if (G)
= no, then give me, nothing.
Thank you to all for your input!

 
Reply With Quote
 
jazdwit07@aol.com
Guest
Posts: n/a
 
      4th Jan 2006
hi
thanks, bob. you are close, but i think i may have confused you (again)
with what i am trying to do. as i had a chance to study my columns
further, let me try to logically explain. i want to find out that if
column G has a YES and column I has a date that is <=1/4/2005, then,
give me Y; or if G has a YES and column I has a date that is >1/4/2005
then give me CK; but if G has NO then give me, nothing. how's that?

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RE: Iff Statements Klatuu Microsoft Access Queries 2 23rd May 2008 12:30 PM
Multiple Update Set Statements or Multiple DML Statements in one thedudeminds@msn.com Microsoft Access Queries 4 11th Sep 2007 06:34 PM
IF Statements (Mutliple Statements) =?Utf-8?B?RGVlemVs?= Microsoft Excel Worksheet Functions 3 19th Oct 2006 06:13 AM
operator statements, shorting when reusing one of the statements? KR Microsoft Excel Programming 1 4th Aug 2005 06:20 PM
IF statements =?Utf-8?B?Sm9zZSBNb3VyaW5obw==?= Microsoft Excel Worksheet Functions 2 27th Dec 2004 09:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:36 AM.