ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VB worksheet function parms (https://www.excelbanter.com/excel-programming/332697-vbulletin-worksheet-function-parms.html)

Mark H[_2_]

VB worksheet function parms
 
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?

Chip Pearson

VB worksheet function parms
 
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


"Mark H" wrote in message
...
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?




Mark H[_2_]

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

"Chip Pearson" wrote:

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


"Mark H" wrote in message
...
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?





Jake Marx[_3_]

VB worksheet function parms
 
Hi Mark,

Mark H wrote:
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]


"Chip Pearson" wrote:

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


"Mark H" wrote in message
...
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?



All times are GMT +1. The time now is 07:17 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com