Function with parameter "as range"

G

Guest

What are you supposed to pass to a function that has a parameter "range" data
type? I have tried the following:
msgbox functionname(range("a1:a10").address)
msgbox functionname(range("a1:a10").range)
msgbox functionname(range("a1:a10"))
msgbox functionname("a1:a10")
msgbox functionname(a1:a10)
 
T

Tushar Mehta

What are you supposed to pass to a function that has a parameter "range" data
type? I have tried the following:
msgbox functionname(range("a1:a10").address)
msgbox functionname(range("a1:a10").range)
msgbox functionname(range("a1:a10"))
msgbox functionname("a1:a10")
msgbox functionname(a1:a10)
And, what were the results?

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
 
B

Bob Phillips

It should be

msgbox functionname(range("a1:a10"))


What hapopens when you do that? Can it handle multiple cells?

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)
 
G

Guest

Mike

an example:

Function FunctionName(ByVal rng As Range)
N = 0
For Each cell In rng
N = N + cell.Value
Next
FunctionName = N
End Function

Sub test()
MsgBox FunctionName(Range("g1:g5"))
End Sub

Or from a worksheet:
=FunctionName(g1:g5)

HTH
 
G

Guest

It should be like this
msgbox functionname(range("a1:a10"))

Which is passing cells A1:A10 of the acitve sheet to the function. If that
is not working you will need to post your code...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top