pokemon_Man
pokemon_Man

Reputation: 902

Pass two value to a sub routine

I'm trying to pass a target.value and target.address to my sub routine, but for some reason i'm getting error "Expected: =".

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

Upvotes: 1

Views: 44

Answers (1)

Brad
Brad

Reputation: 1480

You are missing Call in front of your function.

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

Upvotes: 1

Related Questions