Copy formulas as text

MetLife

Active Member
Joined
Jul 2, 2012
Messages
337
Office Version
  1. 365
Hi,

I have a column of formulas, and I want to copy the formula's text into another column in excel.

So I have something like

A1 = "=Vlookup(B3,...)"
A2 = "=Vlookup(B3,...)"
....
A100 = "=Vlookup..."

And I want to copy cells A1 through A100 to column C, such that it has the text only.

C1 = "Vlookup(B3,...)"
C2 = "Vlookup(B3,...)"
....
C100 = "Vlookup..."

How can I do this?

Thanks
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
OK, I figured it out!

Just copy to Notepad and then back to excel.

Thanks
 
Upvote 0
There is also a function in more recent versions of Excel (I think it's Excel 2013 and later) called FORMULATEXT

Typing =FORMULATEXT(A1) would return the formula contained in cell A1. This should save you a bit of messing about with Notepad!
 
Upvote 0
Actually this is not working because there are "=" signs in the formulas!
 
Upvote 0
If you do not have the newer versions of Excel that have the FormulaText function, you can create your own.

Here is a real short User Defined Function that will do what you want. Just place it in a General/Standard module, and then use like any other function in your workbook.
Code:
Function TextOfFormula(cell As Range) As String
    
    If cell.Count > 1 Then
        TextOfFormula = "Too many cells"
    Else
        TextOfFormula = Format(cell.Formula, "@")
    End If
    
End Function
So, if you want to return the formula in cell E1, you work just use the function:
=TextOfFormula(E1)
 
Last edited:
Upvote 0
If you do not have the newer versions of Excel that have the FormulaText function, you can create your own.

Here is a real short User Defined Function that will do what you want. Just place it in a General/Standard module, and then use like any other function in your workbook.
Code:
Function TextOfFormula(cell As Range) As String
    
    If cell.Count > 1 Then
        TextOfFormula = "Too many cells"
    Else
        TextOfFormula = Format(cell.Formula, "@")
    End If
    
End Function
So, if you want to return the formula in cell E1, you work just use the function:
=TextOfFormula(E1)

Thanks!
 
Upvote 0

Forum statistics

Threads
1,226,416
Messages
6,190,932
Members
453,625
Latest member
SW82SW

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