Excel Macro to Insert a Formula

When I am creating a file for my training or for my blog or other articles that I write I regularly use the FORMULATEXT function to display the formula in a cell on the right of the actual formula. To save time I created a macro to do the work for me.

The macro is used is shown below.

Sub InsertFormulaText()
 
' Inserts the FORMULATEXT function in the selected range
 
' refers to the cell on the left of the selected range
 
Selection.Formula = "=FORMULATEXT(RC[-1])"
 
End Sub

The RC[-1] is a relative reference to the column on the left. The -1 after the C means refer to the column on the left. A positive number would refer to a column on the right.

You select the range before running this macro.

This macro saves me a few keystrokes each time I use it as I run it off the Quick Access Toolbar.

See this post on running macros from the Quick Access Toolbar.

If you are new to macros check out this free webinar on Macros. It includes a pdf manual.

Please note: I reserve the right to delete comments that are offensive or off-topic.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

3 thoughts on “Excel Macro to Insert a Formula