Reference Cell Content

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How would I reference the content of a cell instead of the result?

Example:
A1: =IF(1,2,0) (Result is 2 formatted as number)
A2: ???? (Result is "=IF(1,2,0)" formatted as text)
 
Sloth wrote...
How would I reference the content of a cell instead of the result?

Example:
A1: =IF(1,2,0) (Result is 2 formatted as number)
A2: ???? (Result is "=IF(1,2,0)" formatted as text)

Excel provides no built-in support for this, so you need to use
programming or add-ins. The simplistic approach would be to use XLM
function calls in defined names. Given your example, move to cell A2,
define a name like f1up referring to

=GET.FORMULA(A1)

and enter the formula =f1up in cell A2. The BIG drawback to this is
that in older versions of Excel (2000 and prior), copying a cell with a
formula referring to defined names that call XLM functions and trying
to paste into other worksheets will CRASH Excel. The lesser drawback is
that this approach is inflexible.

The programming option involves writing a user-defined function in VBA.
Put the following code in a general VBA module.

Function ft(r As Range) As String
ft = r.Areas(1).Cells(1, 1).Formula
End Function

In your example, enter the formula =ft(A1) in cell A2.

The add-in approach involves downloading and installing Laurent
Longre's MOREFUNC.XLL add-in, available from
http://xcell05.free.fr/english/ . It provides a function names
FORMULATEXT that does what you want. Enter =FORMULATEXT(A1) in cell A2.
 

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