i can not send target to my sub

  • Thread starter Thread starter benbenben
  • Start date Start date
B

benbenben

i dim a sub named test(r as range)
And I call this sub in the worksheet_selectionchange event as below
But the VB stop it with error messege .said , it need a object
how can i solve it?
pls help me
the program is below:

Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
test(activework.sheets("sheet1").range("A1:B2"))
'this sentense work
test (Target)
'this sentense doesnt work
End Sub

Sub test(r As Range)
MsgBox "OK"
End Su
 
I can't see that either will work, as you don't need the parentheses for
calling a sub. This is required when calling a function and returning the
result to a variable, like

myVar = myFunc(arg1, arg2)

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Back
Top