# IF equal, but not equal to 100

How would I write this to say:  If ShipTabCol1 = ShipTabRowAboveMe but not = to 100?

``````If ShipTabCol1 = ShipTabRowAboveMe Then  'are they equal?'
Exit For
End If
``````
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Older than dirtCommented:
``````If ShipTabCol1 = ShipTabCol1.Offset(-1,0) And ShipTabeCol1 <> 100 Then
' Equal but not 100
End If
``````
Author Commented:
Thanks I am try a variant of this, but I cannot use an offset...  these are two defined. values being used in UFT and SAP.
Is there a way to write this without using the .offset?
Older than dirtCommented:
What do you mean when you say they are "defined values"?
Author Commented:
I think it was the use of the Or instead And.  Testing with
If ShipTabCol1 = ShipTabRowAboveMe And ShipTabCol1 <> "100" Then
Author Commented:
Ok I am reversing the needed statement.  I need to Exit For in the following:

If Value1 and Value2 are equal   or
If Value1 is "" and Value2 is <>""
Older than dirtCommented:
If you really want "Or" then here are two ways to do it

If (Value1 = Value2) Or (Value1 = "" And Value2 <> "")

If (Value1 = Value2) Or (Value1 = "" And Value2 <> Value1)

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Author Commented:
Rats...  I forgot a piece.  When Value1 and Value2 are equal, it is ok only if they are both = to 100.
Do not Exit For if they are = to 100 only.

so something like
If (ShipTabCol1 = ShipTabRowAboveMe and ShipTabCol1 <> "100") Or (ShipTabCol1 = "" And ShipTabRowAboveMe <> ShipTabCol1) Then

test this now.
Author Commented:
Hear is the layout which probably would have help from the beginning.  Sorry
Need one If state that can cover the following.

Value1 = 100  and Value2 = 100,  Do not Exit For

The rest are Exit For,  one missed mismatch and the rest = to each other, just not = 100

Value1 = ""  and Value2 = 100,  Exit For
Value1 = 200  and Value2 = 200,  Exit For
Value1 = 300  and Value2 = 300,  Exit for
etc..

Hope this makes sense
Author Commented:
Thanks for the help.
Older than dirtCommented:
``````If (Value1 = Value2 And Value1 <> 100) Or (Value1 = "" And Value2 = 100) Then
Exit For
End If
``````
Older than dirtCommented:
You're welcome and I'm glad I was able to help. My post above does exactly what you described in post ID: 40820730.

In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2015
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.