Format when sending a range as parameter to a custom function
Something like this... (hard to tell from your question)
Public Sub SendRange()
Dim dblAmount As Double
dblAmount = RecieveRange(Sheets("Sheet1").Range("A1:A5"))
MsgBox "The total is " & dblAmount
End Sub
Public Function RecieveRange(ByVal MyRange As Range) As Double
Dim rng As Range
Dim dblTotal As Double
For Each rng In MyRange
dblTotal = dblTotal + rng.Value
Next rng
RecieveRange = dblTotal
End Function
--
HTH...
Jim Thomlinson
"George Furnell" wrote:
Hello,
I created a custom functiom for which I need to send a range (A1:A5), that I
will loop throu in my function.
Please indicate what the funtion definition will looklike, ie how do I
specify that it will receive a range in that format? I do have the code that
will loop through the cells.
Kind regards
George
|