Link to home
Start Free TrialLog in
Avatar of ilrosebud26
ilrosebud26Flag for United States of America

asked on

Hep with syntax on logic statement in vb

I am having a problem with getting the syntax correct on the below statement:
If Range("A2").Value = "New" And Range("C2") > 0 And Range("C8") > 0 And (IsEmpty(WS.Range("T6")) Or IsEmpty(WS.Range("W6"))) Then

What I need to test is if the value of A2 of current worksheet is equal to new and the value of C2 of the current worksheet is greater than zero and the value of C8 of the current worksheet is greater than zero, if T6 or  W6 is empty.  I have tried serveral different ways of placing the open and close parentheses with no success.

What am I doing wrong?
ASKER CERTIFIED SOLUTION
Avatar of zorvek (Kevin Jones)
zorvek (Kevin Jones)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
New is case senitive

ie

If ucase(Range("A2").Value) = "NEW" And Range("C2") > 0 And Range("C8") > 0 And (IsEmpty(WS.Range("T6")) Or IsEmpty(WS.Range("W6"))) Then
Avatar of ilrosebud26

ASKER

Kevin-
    I get a syntax error with the statement provided.

Rosemary
Kevin-
     I figured out what the syntx problem is but now I am getting a type mismatch error.  Can you help with that?

Rosemary
Can the problem be that cells C2 and C8 are text not numeric?
Let's first make sure everything is correctly qualified:

If Range("A2").Value = "New" And WS.Range("C2").Value > 0 And WS.Range("C8").Value > 0 And (IsEmpty(WS.Range("T6") Or IsEmpty(WS.Range("W6"))) Then

Kevin
Kevin--
Sorry, same error message.
Rosemary

P.S.  If I take the OR logic out of the statement and execute them one at a time there is no error.
Kevin-
    I have it all figured out.  As always, thanks for your help.

Rosemary