Pass a range object as a parameter
Hi Clara,
to call sub procedures, you can use
Call SubName(RangeObject)
or
SubName RangeObject
--
Hope that helps.
Vergel Adriano
"clara" wrote:
Hi Vergel,
Thank you very much! Syntax I used is like "SubName (RangeObjcet)", it
doesn't work, but when I use "Call SubName(RangeObject)" it works.
Clara
--
thank you so much for your help
"Vergel Adriano" wrote:
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
|