How do I refer to a 'formula' instead of the result of that formu

M

MES

I am trying to use a cell reference in one worksheet to a formula in another
worksheet, and want to use the formula itself instead of the result of that
formula, can anyone advise me how to do this?
 
C

Chris Marlow

Hi,

I don't know if there is an existing Excel worksheet function to do this,
but the following VBA will;

Public Function ReturnFormula(Target As Range) As String

ReturnFormula = Target.Cells(1, 1).Formula

End Function

Regards,

Chris.
 
M

MES

MES said:
I am trying to use a cell reference in one worksheet to a formula in another
worksheet, and want to use the formula itself instead of the result of that
formula, can anyone advise me how to do this?
 
F

fasta13

This just returns the formula as a text, is there a way that it will
calculate the function instead of showing the contents?
 
G

Gord Dibben

It is not clear to me what you want to do.

Can you post a formula and desribe what you want to do with it?

Maybe this UDF?

Function EvalCell(RefCell As String)
Application.Volatile
EvalCell = Evaluate(RefCell)
End Function

=evalcell(cellref)

Which does nothing more than return the value from the formula in cellref.

Just as easy to enter =cellref

Evalcell function is handy to return a value from a string such as

1+2+3


Gord Dibben MS Excel MVP
 
Top