Kris,
Objects are always passed by reference. ByVal or ByRef indicates how the
pointer is passed to the function. If the pointer is passed ByRef, the
called procedure can change the object to which the argument refers and this
will be changed in the calling procedure. If the pointer is passed ByVal,
the object reference isn't changed in the calling procedure.
For example,
Sub Test1()
Dim Rng As Range
Set Rng = Range("A1")
Debug.Print "Before ByVal: " & Rng.Address
ByValExample Rng
Debug.Print "After ByVal: " & Rng.Address
Set Rng = Range("A1")
Debug.Print "Before ByVal: " & Rng.Address
ByRefExample Rng
Debug.Print "After ByVal: " & Rng.Address
End Sub
Sub ByValExample(ByVal R As Range)
Set R = Range("B1")
End Sub
Sub ByRefExample(ByRef R As Range)
Set R = Range("B1")
End Sub
--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)
"kris" wrote in message
...
How Workbook objects are passed into functions, is it passed as copy of
workbook or is passed as reference? please help me