UDF to reference the cell with the function in it

  • Thread starter Thread starter lisamariechemistry
  • Start date Start date
L

lisamariechemistry

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!
 
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.
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top