ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   UDF to reference the cell with the function in it (https://www.excelbanter.com/excel-programming/392630-udf-reference-cell-function.html)

[email protected]

UDF to reference the cell with the function in it
 
So I wrote this lovely Function, to be used from the worksheet. (in
the cell, you would enter = & the name of the function & parameters).
It assumes (wrongly, I see now) that the cell you're typing the
formula into is the active cell and pulls a bunch of other data based
on that. What I realized when I tried to filldown, is that it
recalculates everything based on the active cell. I need it to
calculate based on the cell that the formula actually resides in,
rather than the active cell. Any ideas on how I can tell my formula
to reference the cell it's being called from? Thanks!


Harlan Grove[_2_]

UDF to reference the cell with the function in it
 
wrote...
So I wrote this lovely Function, to be used from the worksheet. (in
the cell, you would enter = & the name of the function & parameters).
It assumes (wrongly, I see now) that the cell you're typing the
formula into is the active cell and pulls a bunch of other data based
on that. What I realized when I tried to filldown, is that it
recalculates everything based on the active cell. I need it to
calculate based on the cell that the formula actually resides in,
rather than the active cell. Any ideas on how I can tell my formula
to reference the cell it's being called from? Thanks!


Replace all references to ActiveCell with Application.Caller. You may want
to add logic that tests whether Application.Caller is of type Range.



[email protected]

UDF to reference the cell with the function in it
 
Thank you! That's exactly what I needed. I fiddled about with
variations on call and called, so I was sort of on the right track.




All times are GMT +1. The time now is 07:25 PM.

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