Alex Michel
Alex Michel

Reputation: 436

Get reference to cell containing function

Is there is way to access cell that contains my UDF? I need to reset some cache when function with same parameters is run from different cell. Didn't find anything suitable in exceldna utils.

Thanks, Alex

Upvotes: 3

Views: 2458

Answers (1)

Govert
Govert

Reputation: 16907

You can call

ExcelReference caller = XlCall.Excel(XlCall.xlfCaller) as ExcelReference;

The result will be an ExcelReference if you're called from a sheet formula. It might be null if you're called via Application.Run or a few other ways.

ExcelReference is a wrapper for the C API sheet reference.

Upvotes: 4

Related Questions