ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   intersection with linear range as true argument (https://www.excelbanter.com/excel-programming/336790-intersection-linear-range-true-argument.html)

TACTG

intersection with linear range as true argument
 
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.


Tom Ogilvy

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.





All times are GMT +1. The time now is 09:05 AM.

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