function to return a functions formula

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.
 
J

Jim

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).
 
V

Vasant Nanavati

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.
 
G

Gord Dibben

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
 

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

Top