Retrieve Formula from cell not value

%3CLINGO-SUB%20id%3D%22lingo-sub-1587475%22%20slang%3D%22en-US%22%3ERetrieve%20Formula%20from%20cell%20not%20value%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1587475%22%20slang%3D%22en-US%22%3E%3CP%3EI%20need%20to%20retrieve%20the%20existing%20formula%20from%20a%20cell%20not%20the%20value%20of%20the%20formula.%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3Ewhat%20function(s)%20do%20I%20use%20to%20do%20that%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1587475%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1587481%22%20slang%3D%22en-US%22%3ERE%3A%20Retrieve%20Formula%20from%20cell%20not%20value%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1587481%22%20slang%3D%22en-US%22%3E%3DFORMULATEXT(cellreference)%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1587484%22%20slang%3D%22en-US%22%3ERe%3A%20Retrieve%20Formula%20from%20cell%20not%20value%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1587484%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F758831%22%20target%3D%22_blank%22%3E%40Don_Raflik%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20can%20try%26nbsp%3BFORMULATEXT%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECheers%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1587534%22%20slang%3D%22en-US%22%3ERE%3A%20Retrieve%20Formula%20from%20cell%20not%20value%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1587534%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F425987%22%20target%3D%22_blank%22%3E%40mathetes%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ethank%20you%20for%20your%20reply.%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3EI%20am%20working%20in%20VBA.%20I%20did%20find%20an%20answer%20that%20worked.%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%3D%20.cells(cellrefernce).formula%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1587707%22%20slang%3D%22en-US%22%3ERE%3A%20Retrieve%20Formula%20from%20cell%20not%20value%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1587707%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F758831%22%20target%3D%22_blank%22%3E%40Don_Raflik%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThat%20would%20do%20it.%26nbsp%3B%20If%20your%20version%20of%20Excel%20does%20not%20feature%20FORMULATEXT()%20you%20could%20emulate%20it%20with%20a%20UDF%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-basic%22%3E%3CCODE%3EFunction%20showFormula(target%20As%20Range)%20As%20String%0A%20%20%20%20showFormula%20%3D%20target.Formula%0AEnd%20Function%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ecalled%20with%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3D%20showFormula(cellRef)%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20Formula%20property%20and%20its%20variants%20can%20also%20be%20set%20from%20VBA%2C%20allowing%20the%20worksheet%20to%20be%20built%20from%20code.%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

I need to retrieve the existing formula from a cell not the value of the formula. 

what function(s) do I use to do that?

4 Replies
=FORMULATEXT(cellreference)

@Don_Raflik 

 

You can try FORMULATEXT

 

Cheers

@mathetes 

 

thank you for your reply. 

I am working in VBA. I did find an answer that worked. 

= .cells(cellrefernce).formula 

@Don_Raflik 

That would do it.  If your version of Excel does not feature FORMULATEXT() you could emulate it with a UDF

 

Function showFormula(target As Range) As String
    showFormula = target.Formula
End Function

 

called with

= showFormula(cellRef)

 

The Formula property and its variants can also be set from VBA, allowing the worksheet to be built from code.