将两个值传递给子例程
我试图将一个target.value和target.address传递给我的子例程,但由于某种原因,我得到错误“预期:=”。
Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "$A$2" Then sendToRoutine (Target.Address, Target.Value) <<== Error End If End Sub Sub sendToRoutine ( myTarget as String, myTargetValue as String) 'Do Something with the values.... End Sub
您在function前面缺lessCall
。
Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "$A$2" Then Call sendToRoutine(Target.Address, Target.Value) '<<== Not an error End If End Sub Sub sendToRoutine(myTarget As String, myTargetValue As String) 'Do Something with the values.... End Sub