Defining a function to use multiple places in code
Let's say I want to pass a string and a value from RC7 of the open workbook
to the function. How would I set up the function.
This is what I have so far:
Function row(lookup As String, range As String) As Variant
row = "=MATCH(lookup,indirect(""'[""&range&""]Sheet1'!""&C2),TRUE),0)"
Debug.Print row
End Function
In the match function, I want it to check COLUMN 2.
How do I do this?
"NickHK" wrote:
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
|