Display actual typed formula in a cell

winvj

New Member
Joined
Nov 29, 2021
Messages
3
Office Version
  1. 2007
Platform
  1. Windows
Hi guys we need your help for my below query.

I typed a calculation in cell A1 like =45+89+15 and the value shows 149 in same cell

I need to display the Calculated items which is "=45+89+15" in another cell B1.

How to do this either function or VBA

Advance thanks for your help.
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
There is no built-in function in 2007 for that (2016 and later have FORMULATEXT) so you'd need a UDF written in VBA - for example:

Code:
Function GetFormulaText(Input as range) as string
getformulatext = input.cells(1).Formula
end function

then just use
Excel Formula:
=GetFormulaText(A1)
in B1
 
Last edited:
Upvote 0
There is no built-in function in 2007 for that (2016 and later have FORMULATEXT) so you'd need a UDF written in VBA - for example:

[ode]Function GetFormulaText(Input as range) as string
getformulatext = input.cells(1).Formula
end function[/code]

then just use
Excel Formula:
=GetFormulaText(A1)
in B1
Hi Rory

thanks for your reply.

can you please explain. i am a beginner of excel, also mentioned the right formula which i need to cut & paste.

the line getformulatext = input.cells(1).Formula is showing error.

thank you.
 
Upvote 0
You need to open the VB Editor (Alt+f11) then with your workbook active, choose Insert - Module from the menu. Then paste in the code I posted:

Code:
Function GetFormulaText(Input as range) as string
getformulatext = input.cells(1).Formula
end function

You can then switch back to Excel and use the formula I suggested.
 
Upvote 0
another alternative follows

If you require a more complex solution, please advise.

T202111a.xlsm
ABC
1149=45+89+15=45+89+15
5d
Cell Formulas
RangeFormula
A1A1=45+89+15
B1B1=gf(A1)
C1C1=GetFormula(A1)


VBA Code:
Function GF(Rng As Range) As String
  GF = Rng.Formula
End Function


Function GetFormula(Rng As Range) As String
 GetFormula = Rng.Formula
End Function
 
Upvote 0
Solution
another alternative follows

If you require a more complex solution, please advise.

T202111a.xlsm
ABC
1149=45+89+15=45+89+15
5d
Cell Formulas
RangeFormula
A1A1=45+89+15
B1B1=gf(A1)
C1C1=GetFormula(A1)


VBA Code:
Function GF(Rng As Range) As String
  GF = Rng.Formula
End Function


Function GetFormula(Rng As Range) As String
 GetFormula = Rng.Formula
End Function
thank you so much. it is working fine....
 
Upvote 0

Forum statistics

Threads
1,215,059
Messages
6,122,918
Members
449,094
Latest member
teemeren

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top