[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
8
Medium Priority
?
307 Views
Last Modified: 2010-05-19
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
Comment
Question by:ilrosebud26
  • 5
  • 2
8 Comments
 
LVL 81

Accepted Solution

by:
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

by:EDDYKT
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

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

Rosemary
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:ilrosebud26
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

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

Expert Comment

by:zorvek (Kevin Jones)
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

by:ilrosebud26
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

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

Rosemary
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

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…

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question