0

is it possible to call a subroutine in VBA using a concatenation of strings? For example

Sub Call_This_2019()
   ' do something
end sub

Sub From_this()
   Call ("Call_This_" + str(2019))
Sub

I haven't had any luck using this approach.

  • 1
    [This question](https://stackoverflow.com/q/2695198/2127508) discusses a similar issue and may be helpful – barrowc Mar 13 '19 at 23:32

1 Answers1

0

I googled 'vba calling dynamic subroutine' and I found this at http://www.vbaexpress.com/forum/showthread.php?36844-Solved-Dynamic-Procedure-call

Sub Call_This_2019()
   ' do something
   MsgBox ("Got here")
End Sub

Sub From_this()
    Dim theCallee As String
    theCallee = "Call_This_" & LTrim(Str(2019)) ' LTrim removes leading blank
    'Call theCallee         ' Syntax error
    'Call Eval(theCallee)   ' 2766 no Application object
    Application.Run theCallee
End Sub
donPablo
  • 1,937
  • 1
  • 13
  • 18