Public Sub test()
a = 1
Select Case a
Case Is > 0 And Not 1
MsgBox "Hey"
End Select
End Sub
It is possible but your syntax is incorrect. When you write Case Is > 0 And Not 1 you're saying if a is greater than (zero And Not 1). VBA evaluates the expression (zero And Not 1) before it performs the comparison in exactly the same way as you'd expect If a > b+1 to evaluate b+1 before it compared the resulting value to a.This is very, very annoying. The messagebox appears. Why? Is it not possible to use And in a Select Case statement?
Code:Public Sub test() a = 1 Select Case a Case Is > 0 And Not 1 MsgBox "Hey" End Select End Sub
Select Case TRUE
Case a > 0 And a <> 1