开发者

excel vba call multiple subroutines in select case

If I have the following code:

Select Case Number

  Case 1: Call Subroutine1()
  Case 2: Call Subroutine2()
  Case 3: Call Subroutine3()
  Case 4: Call Subroutine4()
  Case 5: Call Subroutine5()
  Case 6: Call Subroutine6()

End Select

and I want to call several subroutines in case 1:

How 开发者_开发技巧can it be done?

best, US


Select Case Number

  Case 1: 
    Call Subroutine1a()
    Call Subroutine1b()
    Call Subroutine1c()

  Case 2: Call Subroutine2()
  Case 3: Call Subroutine3()
  Case 4: Call Subroutine4()
  Case 5: Call Subroutine5()
  Case 6: Call Subroutine6()

End Select


Like this:

Select Case Number

  Case 1: 
      Call Subroutine1a()
      Call Subroutine1b()
  Case 2: Call Subroutine2()
  Case 3: Call Subroutine3()
  Case 4: Call Subroutine4()
  Case 5: Call Subroutine5()
  Case 6: Call Subroutine6()

End Select


You can have as many statement in each Case match as you like;

Select Case Number
  Case 1
    Call Subroutine1()
    Call Subroutine2()
  Case 2: Call Subroutine2()
  ...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜