function to return a functions formula

  • Thread starter Thread starter Bart
  • Start date Start date
B

Bart

I'm looking for a function to return the syntax/text of a
funciton in a cell (=10+10)instead of the value (20) in
the cell. Please help.
 
From Help, with Show Formulas as the search term:

Display or hide formulas
Switch between displaying formulas and their values on a worksheet
Press CTRL + ` (grave accent).
 
Put the following function in a standard module in your workbook:

Function TextOfFormula(rng As Range) As String
If rng.HasFormula Then TextOfFormula = rng.Formula
End Function

Then enter into any cell:

=TextOfFormula(A1)

to display the formula in A1.
 
Bart

If the 10 and 10 are returned from cell references...........

="=" & A2 & " + " & B2

With 10 in A2 and 10 in B2 the above would return =10 + 10

Gord Dibben XL2002
 
Back
Top