tags:

views:

3425

answers:

3

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)
+2  A: 

A2 is already a relative reference and will change when you move the cell or copy the formula.

Joey
Don't worry about addressing style. All formulas use R1C1 internally anyway, it doesn't matter.
GSerg
Ah, thanks. Didn't bother to look it up right now (wading through the XML isn't exactly fun usually :))
Joey
+3  A: 

You could use

=CELL("width", INDIRECT(ADDRESS(ROW(), COLUMN())))

but Johannes's answer will work just as well

Patrick McDonald
This makes the formula volatile. Therefore, provided there are non-volatile solutions, don't use this one.
GSerg
+5  A: 

Leave off the second argument entirely, it is an optional argument. When you omit it, the function uses the host cell as the reference.

=CELL("width")

Dick Kusleika