Given
Select Case cmd
case "ONE": MsgBox "one"
case "TWO": MsgBox "two"
case "THREE": MsgBox "three"
End select
My requirement is if cmd = "ONE"
I need "one"
and then "two"
displayed however currently I am getting "one"
displayed and then the program is breaking out of the select case...
VBA Switch Case – Example #1Step 1: Insert a new module inside Visual Basic Editor (VBE). Click on Insert tab > select Module. Step 2: Define a new subprocedure within the inserted module that can hold your macro. Step 3: Define a new variable named usrInpt which can hold the user value.
If testexpression matches any Case expressionlist expression, the statements following that Case clause are executed up to the next Case clause, or, for the last clause, up to End Select.
Select Case is useful when you have three or more conditions that you want to check. You can also use this with two conditions (but I feel If Then Else is easier to use in those cases).
Select Case cmd
case "ONE", "TWO":
if cmd = "ONE" THEN
MsgBox "one"
end if
MsgBox "two"
case "THREE": MsgBox "three"
End select
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With