View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default If ... < or ... < then statement

When MyType equals "DIV", MyType does not equal "UNM" and it does not equal
"MOD", so the entire statement becomes

If FALSE Or TRUE Or TRUE Then
blah blah
End If

or

If TRUE Then
blah blah
End If

In fact, your code will always go in to the Then statement, regardless of
the contents of MyType. In spoken English, we tend to use Or in this sort
of statement when we really mean And. You don't want Or's here, you want
And's.

If MyType < "DIV" And MyType < "UNM" And MyType < "MOD" Then


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
www.cpearson.com


"zsplash" wrote in message
...
I think I must not understand the "or" (and <) qualities of code, in an
If-Then statement.



Here's my code:

If MyType < "DIV" Or MyType < "UNM" Or MyType < "MOD" Then
blah, blah, blah

End If



When MyType = "DIV", the code progresses to the [blah, blah, blah]. My
little brain is trying to think that if MyType = "DIV", the code should
bypass the [blah, blah, blah].



Please enlighten me.



TIA