View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
NickHK[_3_] NickHK[_3_] is offline
external usenet poster
 
Posts: 415
Default Defining a function to use multiple places in code

Make your function public in a module, then call it from whereever you need
its functionality. As a trivial example :

' In a module
Public Function GetVal(argRange as Range) as variant
GetVal=argRange.Value
End function

' Call the function from anywhere
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
MsgBox GetVal(Target)
End Sub

NickHK

"Barb Reinhardt" ...
I have a function that I need to use multiple places in my code, but don't
want to have to type it over and over. Could someone give an example of
how
I'd set it up and use it? You can give a simple example and I'll fill in
my
own data.

Thanks,
Barb Reinhardt