开发者

excel vba call multiple subroutines in select case

开发者 https://www.devze.com 2023-03-13 08:13 出处:网络
If I have the following code: Select Case Number Case 1: Call Subroutine1() Case 2: Call Subroutine2() Case 3: Call Subroutine3()

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

精彩评论

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