View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Vergel Adriano Vergel Adriano is offline
external usenet poster
 
Posts: 857
Default Pass a range object as a parameter

Clara,

You would pass it like Range("A1") for example. The important part is that
the called sub or function must be expecting a range. To demonstrate, paste
the code below in a module. Run the test sub. You will see that Range("A1")
is passed to the two subroutines but PassTheRange gets the range object
because it is expecting a range. PassTheValue gets the default value because
it is expecting a string value.


Sub test()
PassTheRange Range("A1")
PassTheValue Range("A1")
End Sub
Sub PassTheValue(strValue As String)
Debug.Print strValue
End Sub
Sub PassTheRange(r As Range)
Debug.Print r.Address
End Sub




--
Hope that helps.

Vergel Adriano


"clara" wrote:

Hi all,

How to pass a range object instead of to pass it's default value?

Clara
--
thank you so much for your help