How do I obtain a reference to the current cell?
For example, if I want to display the width of column A, I could use the following:
=CELL("width", A2)
However, I want the formula to be something like this:
=CELL("width", THIS_CELL)
In the current worksheet, select cell A1 (this is important!)
Open Name Manager
(Ctl+F3)
Click New...
Enter "THIS_CELL" (or just "THIS", which is my preference) into Name:
Enter the following formula into Refers to:
=!A1
NOTE: Be sure cell A1 is selected. This formula is relative to the ActiveCell.
Under Scope:
select Workbook
.
Click OK
and close the Name Manager
=CELL("width",THIS_CELL)
EDIT: Better solution than using INDIRECT()
It's worth noting that the solution I've given should be preferred over any solution using the INDIRECT()
function for two reasons:
INDIRECT()
is a volatile Excel function, and as a result will dramatically slow down workbook calculation when it is used a lot.ROW()
COLUMN()
) to a range reference to an address and back to a range reference again.EDIT: Also see this question for more information on workbook-scoped, sheet dependent named ranges.
EDIT: Also see @imix's answer below for a variation on this idea (using RC style references). In that case, you could use =!RC
for the THIS_CELL
named range formula, or just use RC
directly.