我試過類似的東西:
sub tester()
'do something
End Sub
activesheet.cells(1,1) = 'tester'
sub foo()
dim x as string
x = activesheet.cells(1,1).value
Call x
End Sub
目的是操縱一個單元格,以便隨著單元格值的變化,被呼叫的 sub 也會發生變化。
uj5u.com熱心網友回復:
使用 Application.Run
- 這是一個錯誤處理的示例,值得一試。
Option Explicit
Sub Test1()
MsgBox "First"
End Sub
Sub Test2()
MsgBox "Second"
End Sub
Sub Foo()
On Error GoTo ClearError
Dim S As String: S = CStr(Range("A1").Value)
Application.Run S
ProcExit:
Exit Sub
ClearError:
MsgBox "Run-time error '" & Err.Number & ":" & vbLf & Err.Description
Resume ProcExit
End Sub
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/437781.html
