View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default intersection with linear range as true argument

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




--

Regards,

Tom Ogilvy



"TACTG" wrote in message
...
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.