Is there any Excel function that returns the body of another function?

Asked

Viewed 126 times

2

Simple example of what I want: suppose in cell A1 I have value 2, in cell A2 I have value 3 and in cell A3 I have formula =A1+A2.

If I put in cell A4 the formula =A3, it will obviously return me the value 5 and what I would like is a formula that returns me the string '=A1+A2'. There is this formula?

From now on, thank you.

  • 2

    You can use the function: =FÓRMULATEXTO(A3)

2 answers

5

You can use the FÓRMULATEXTO()

Example:

plan

Being:

A1 = 10

B1 = 20

C1 = =A1+B1

E1 = =FÓRMULATEXTO(C1)


Complementing

A simple example using the function to mount a calculation memory:

form1

If you use the named interval feature, you can make it look even better...

form2


Reference: Function Tip - FORMULATEXT

  • Thanks for the answer, but this FÓRMULATEXTO function only exists in Office 2013 and my Excel is version 2010.

  • 1

    @Marcelo The reply of danieltakeshi will work for your case. As my answer may serve too much, I will leave it.

2


A User Defined Function (UDF) can be created for Excel 2010 or earlier versions:

Function MostraFormula(Rng As Range, Optional asR1C1 As Boolean = False) As String
    If asR1C1 Then
        MostraFormula = Rng.FormulaR1C1
    Else
        MostraFormula = Rng.FormulaLocal
    End If
End Function

Then entering the following example data:

      A   B        C                 D           
 --- --- --- -------------- -------------------- 
  1   2   3   =SOMA(A1;B1)   =MostraFormula(C1)  
  2                                              
  3   

The result is:

      A   B   C        D        
 --- --- --- --- -------------- 
  1   2   3   5   =SOMA(A1,B1)  
  2                             
  3                             

Or with =MostraFormula(C1; VERDADEIRO) the result is =SUM(RC[-2],RC[-1])

  • Daniel, would that be MACRO? + 1

  • 1

    This is possible only with VBA (macro). Where a custom function is created.

  • It worked! Thank you very much!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.