是否可以使用字符串连接在VBA中调用子例程?例如
Sub Call_This_2019()
' do something
end sub
Sub From_this()
Call ("Call_This_" + str(2019))
Sub
使用这种方法我没有任何运气。
答案 0 :(得分:0)
我搜索了“ vba调用动态子程序”,然后 我在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