-
Oct 16th, 2017, 10:55 AM
#1
Thread Starter
New Member
How do I get .Range to recognize a string value?
I have the following code:
Code:
If .Range("A" & RowCount) = .Range("A" & (RowCount - 1)) _
And .Range("B" & RowCount) = .Range("B" & (RowCount - 1)) _
And .Range("C" & RowCount) = .Range("C" & (RowCount - 1)) _
And .Range("E" & RowCount) = .Range("E" & (RowCount - 1)) _
Or .Range("E" & RowCount) = ("Discount" Or "Gratuity" Or "Tax") Then
I'm having trouble with the Or statement on the last line. What I'm trying to ask on lines 4 and 5 is: (if RowCount = 2) if E2 is equal to E1 Or if E2 is equal to "Discount", "Gratuity", or "Tax". I looked up the .Cell property but that doesn't seem to work either. What's the best way to accomplish this?
Last edited by bishoposiris; Oct 17th, 2017 at 07:55 AM.
Reason: Answered
-
Oct 16th, 2017, 11:00 AM
#2
Re: How do I get .Range to recognize a string value?
This looks like VBA, in which case I can move it to the right forum. However, the Or statement on the last line has trouble in any language. While it would be nice to make it as compact as you have, it simply isn't possible. What you are doing is ORing together the three strings, then comparing that to the range ("E" & RowCount). ORing together three strings, will result in True (or it will crash, which would probably be better, since there's no way that True is the expected result).
You'd have to write it out:
(.Range("E" & RowCount) = "Discount" OR .Range("E" & RowCount) = "Gratuity" OR .Range("E" & RowCount) = "Tax")
My usual boring signature: Nothing
-
Oct 17th, 2017, 07:53 AM
#3
Thread Starter
New Member
Re: How do I get .Range to recognize a string value?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|