I certainly don't know of any way for a function to know which cell called it. The example of ROW() is not relevant, I think, because ROW() requires an argument. The argument is a reference to the cell for which you want to know the row. The value returned depends on that argument, not on what cell called ROW(). You can, however, pass to your function the address of the calling cell. I made this simple function:
- Code: Select all Expand viewCollapse view
Function Tester(arg1, arg2)
On Error GoTo EH
Tester = arg1^0.5
exit function
EH:
Print "This cell caused an error: " & arg2
End function
and then used it in cell B5 like this.
- Code: Select all Expand viewCollapse view
=TESTER(D3; CELL("ADDRESS";B5))
If D3 contains a non-negative number, B5 gets the value of D3^0.5. If D3 is negative, the function prints the message "This cell caused an error: $B$5". Of course, you could make the second argument of Tester just the string "B5". I added the CELL() function so the whole thing can be copied to other cells yet keep the second argument referring to the correct cell. This isn't exactly what you wanted, but it is as close as I know how to get.