View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jake Marx[_3_] Jake Marx[_3_] is offline
external usenet poster
 
Posts: 860
Default How to pass sheet reference to a procedure

Hi djd,

djd wrote:
Due to the number of inputs to the procedure I don't want to pass the
values entered as arguments. The inputs will not be modified only
the costs cells so I was thinking of passing the sheet using ByVal.
I can't find anything that says you couldn't do this in a book. Is
this possible? Any gottcha's in doing this?


I would use ByRef (default, so you can leave it out entirely) since you want
to pass a reference to an object (Worksheet):

Sub demo()
DoCalcs Worksheets("Sheet1")
End Sub

Sub DoCalcs(rwsSource As Worksheet)
MsgBox rwsSource.Name
End Sub

There aren't any gotcha's that I can think of.

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com


[please keep replies in the newsgroup - email address unmonitored]