[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
Solved

# Hep with syntax on logic statement in vb

Posted on 2007-10-09
Medium Priority
307 Views
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?
0
Question by:ilrosebud26
• 5
• 2

LVL 81

Accepted Solution

zorvek (Kevin Jones) earned 500 total points
ID: 20044091
If Range("A2").Value = "New" And Range("C2") > 0 And Range("C8") > 0 And (IsEmpty(WS.Range("T6") Or IsEmpty(WS.Range("W6"))) Then

Kevin
0

LVL 26

Expert Comment

ID: 20047597
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
0

Author Comment

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

Rosemary
0

Author Comment

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

Rosemary
0

Author Comment

ID: 20058138
Can the problem be that cells C2 and C8 are text not numeric?
0

LVL 81

Expert Comment

ID: 20058487
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
0

Author Comment

ID: 20058578
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.
0

Author Comment

ID: 20060329
Kevin-
I have it all figured out.  As always, thanks for your help.

Rosemary
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
###### Suggested Courses
Course of the Month19 days, 7 hours left to enroll