JMongi
Active member
- Local time
- Today, 00:18
- Joined
- Jan 6, 2021
- Messages
- 802
Is there a VBA command that functions similarly to Select Case but without the simple individual source? A normal Select Case is like:
Where MyNum is compared to each expression.
I want to set up something similar but just with expressions.
I can structure this using If/Then but I find this fake structure much easier to read and discern what's going on. Is there VBA function that might work this way?
C-like:
Select Case MyNum
Case 0 : MsgBox "The number is 0"
Case 1 : MsgBox "The number is 1"
Case > 1: MsgBox "The number is greater than 1"
Else: MsgBox "Why did you enter a negative number you negative nelly?"
End Select
Where MyNum is compared to each expression.
I want to set up something similar but just with expressions.
Code:
Select Case
Case Me.UnitNumber = ""
'Do something
Case Len(Me.UnitNumber) <> 7
'Do something
Case IsNum(Left(Me.UnitNumber, 2)) = False
'Do something
Case IsNum(Right(Me.UnitNumber, 4)) = False
'Do something
Case InStr(1,Me.UnitNumber, "-") <> 3
'Do something
End Select
I can structure this using If/Then but I find this fake structure much easier to read and discern what's going on. Is there VBA function that might work this way?