ilrosebud26
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?
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Kevin-
I get a syntax error with the statement provided.
Rosemary
I get a syntax error with the statement provided.
Rosemary
ASKER
Kevin-
I figured out what the syntx problem is but now I am getting a type mismatch error. Can you help with that?
Rosemary
I figured out what the syntx problem is but now I am getting a type mismatch error. Can you help with that?
Rosemary
ASKER
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
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
ASKER
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.
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.
ASKER
Kevin-
I have it all figured out. As always, thanks for your help.
Rosemary
I have it all figured out. As always, thanks for your help.
Rosemary
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