vbaexceloffice-2007

How to fall through a Select Case in Excel VBA?


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...


Solution

  • Select Case cmd
        case "ONE", "TWO":   
                      if cmd = "ONE" THEN
                          MsgBox "one"
                      end if
                      MsgBox "two"
    
        case "THREE": MsgBox "three"
    
    End select