ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   current cell in user-defined function (https://www.excelbanter.com/excel-programming/284782-current-cell-user-defined-function.html)

Julio Kuplinsky

current cell in user-defined function
 
Is the current cell (not the active cell) available in a
user defined function? For instance, can I say

public function foo()

' Give me the row of the worksheet cell where this
' function is entered

end function

Thanks

Bob Phillips[_6_]

current cell in user-defined function
 
Julio,

You can't get the cell details (AFAIK), but you could pass it to the
function, for example

Function foo(rng As Range)
If rng.Count = 1 Then
foo = rng.Row
End If
End Function

and call it like so
=foo(A24)

By making it a relative reference, it will update as you copy to other
cells.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Julio Kuplinsky" wrote in message
...
Is the current cell (not the active cell) available in a
user defined function? For instance, can I say

public function foo()

' Give me the row of the worksheet cell where this
' function is entered

end function

Thanks




Haldun Alay[_3_]

current cell in user-defined function
 
Hi,

Use Application.Caller property.

Function CellRow()
CellAddress = Application.Caller.Row
End Function

when you enter that function in a cell it gives the row number of cell where the function is entered.


--
Regards

Haldun Alay

To e-mail me, please replace AT and DOT in my e-mail address with the original signs.



"Julio Kuplinsky" , iletide sunu yazdi ...
Is the current cell (not the active cell) available in a
user defined function? For instance, can I say

public function foo()

' Give me the row of the worksheet cell where this
' function is entered

end function

Thanks

Haldun Alay[_3_]

current cell in user-defined function
 
Oooppppss!
function will be

Function CellRow()
CellRow= Application.Caller.Row
End Function


--
Regards

Haldun Alay

To e-mail me, please replace AT and DOT in my e-mail address with the original signs.



"Haldun Alay" <haldunalayATyahooDOTcom, iletide sunu yazdi ...
Hi,

Use Application.Caller property.

Function CellRow()
CellAddress = Application.Caller.Row
End Function

when you enter that function in a cell it gives the row number of cell where the function is entered.


--
Regards

Haldun Alay

To e-mail me, please replace AT and DOT in my e-mail address with the original signs.



"Julio Kuplinsky" , iletide sunu yazdi ...
Is the current cell (not the active cell) available in a
user defined function? For instance, can I say

public function foo()

' Give me the row of the worksheet cell where this
' function is entered

end function

Thanks


All times are GMT +1. The time now is 11:39 PM.

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