Display formula in a cell


Posted by Rich Allwes on January 08, 2002 9:05 AM

Is there an existing macro or formula for displaying the formula contained in a cell in another cell.

For example: The number 25 is displaced in cell A3.

I want to list the formula "=3*gamma-beta of cell A3 in cell B3. Gamma and beta are range names of cells.

I would appreciate help in this matter.

Posted by Andy Gee on January 08, 2002 9:25 AM

Why not just type it then format it as text!

Posted by Dat on January 08, 2002 10:15 AM

Push---- Ctrl + ~ at the same time (~ is under the Esc key)

Posted by Chris D on January 08, 2002 10:31 AM

Would you want the displayed formula to change if you changed the original formula, without having to do any typing or anything ?

If you do, I have a very cumbersome non-macro fix which I'm sure can be put to shame by the VBA guys on this site...

If not, then the suggestions below would be what I'd do...

give me a shout
Chris



Posted by Stephen Giles on January 09, 2002 6:29 AM

This code will show the formula in an individual cell:
Function CellFormula(c)
CellFormula = c.Formula
End Function

Press alt+F11, insert a module and paste in the code. If say you want to see the formula in A1, enter =cellformula(A1) in another cell and that formula will appear.