VB worksheet function parms

G

Guest

I've written a worksheet function in VB that is used by entering it in a cell
in the worksheet with two parameters. I'd like to find a way to know what
row or column the passed parameters came from so that I can conditionally
determine the function output based on that row or column. Is there an
object, method or property that will tell me this info about passed
parameters to a VB function?
 
C

Chip Pearson

Unless your function parameters are Range objects, there is no
way to determine where the values came from.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
G

Guest

And if the parameters are range objects, i.e. cell addresses, then what? can
I say parm.col or something?
 
J

Jake Marx

Hi Mark,

Mark said:
And if the parameters are range objects, i.e. cell addresses, then
what? can I say parm.col or something?

If you pass in Range objects, then you can get the column & row like this:

Public Function TESTFUNCTION(range1 As Range, _
range2 As Range) As Variant
TESTFUNCTION = "(" & range1.Row & "," & range2.Column & _
"),(" & range2.Row & "," & range2.Column & ")"
End Function

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]
 

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