intersection with linear range as true argument

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

Most (maybe all) of Excel's built-in functions can take a linear (1x? or
?x1) range as an argument that is ultimately meant to be only a single cell.
The built-in functions interpret/pass the argument as the cell with the same
row or column as the cell from which the function is called depending on
weather the argument range is vertical or horizontal. I would liike to have
this same functionality with my own custom functions. Is there some special
means of doing this or is it necessary to have a sub that is called
internally by all my functions that uses indices, etc. to convert a range
argument to the proper single cell? Does anyone have such a sub already
written that they are willing to share?

Thanks.
 
You have to program the functionality yourself.

Jim Rech once suggested:

==========================
I don't know if you can tell Excel what to pass you but you can build a bit
more flexibility into your function as below. I wouldn't want to have to do
this routinely but fwiw.


Function X(Rg As Range) As Variant
If Rg.Columns.Count > 1 Then
Set Rg = Intersect(Application.Caller.E­ntireColumn, Rg)
ElseIf Rg.Rows.Count > 1 Then
Set Rg = Intersect(Application.Caller.E­ntireRow, Rg)
End If
X = Rg.Value
End Function


--
Jim Rech
Excel MVP
 

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

Back
Top