Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Saving Common Formulas.

Saving Common Formulas

Written by Allen Wyatt (last updated September 24, 2024)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


6

Sometimes, creating just the formula you want can be a victory all in itself. Once created, formulas become valuable, and you may need to use them over and over again in different worksheets you use. Wouldn't it be great to have a way to paste commonly used formulas in a workbook, the same way you can paste clip art or other common objects?

Unfortunately, such a capability is not resident within Excel. There are a couple of things you can do to make your formulas more accessible, however. One thing you can do is keep a text document (a Notepad document) on your desktop and store your commonly used formulas in it. With Excel open, you can open the text document, copy the desired formula to the Clipboard, and quickly paste it in the desired cell of the workbook.

Another possible solution is to assign names to your formulas.

  1. Enter your formula as you normally would.
  2. Select the cell containing the formula and press F2. This places Excel in edit mode.
  3. Hold down the Shift key as you use the cursor control keys to select the entire formula, including the equal sign at its very beginning.
  4. Press Ctrl+C. The formula is now on the Clipboard.
  5. Press Esc. You should now be out of edit mode, and the cell with the formula is still selected.
  6. Make sure the Formulas tab of the ribbon is selected.
  7. In the Defined Names area, click the Define Name option. Excel displays the New Name dialog box. (See Figure 1.)
  8. Figure 1. The New Name dialog box.

  9. In the Name box, enter the name you want assigned to this formula.
  10. Select whatever is in the Refers To box, at the bottom of the dialog box, and press Ctrl+V. The cell reference is replaced with the formula that was copied to the Clipboard in step 4.
  11. Make sure there are no dollar signs in the formula. If there are, select them and delete them. (This method of using formulas does not work well with absolute references.)
  12. Click OK.

Now, whenever you want to use the formula, you simply enter an equal sign and the name you gave to the formula in step 8. Even though the name shows in the cell, the formula assigned to the name is actually used in doing the calculation. Since the formula used relative references (you got rid of the dollar signs), it is always relative to where you use the name in the worksheet.

Another approach works great if you are comfortable with macros and with the VB Editor. This approach involves making your common formulas part of your Personal macro workbook. This workbook is opened whenever you start Excel and is designed primarily for macros and customizations that you want available whenever you use Excel. But there is no reason it cannot be used for common formulas, as well.

Assuming you haven't yet created a Personal macro workbook, follow these steps:

  1. Start Excel with a new workbook.
  2. Display the View tab of the ribbon.
  3. Click the down-arrow under the Macros tool and then click Record Macro. Excel displays the Record Macro dialog box. (See Figure 2.)
  4. Figure 2. The Record Macro dialog box.

  5. Using the Store Macro In drop-down list, choose Personal Macro Workbook.
  6. Click OK. The Macro Recorder is now running.
  7. Select any cell in the worksheet. (It doesn't matter which one you choose.)
  8. Click Stop Recording on the ribbon's Developer tab.

The macro you recorded is now stored in your newly created Personal macro workbook. To see the code that you created, open the VB Editor (Alt+F11). In the upper-left corner of the editor is the Project Explorer; it lists all the various pieces and parts accessible through the editor. One of the items in the Project Explorer should be PERSONAL.XLSB. If you expand this object (click the small plus sign to the left of the project name), you should see a Modules folder. Expand the Modules folder, and it contains Module1. If you double-click on this module you see the macro you just recorded; it looks something like this:

Sub Macro1()

' Macro1 Macro
'

'
    Range("A4").Select
End Sub

You can now select this code and delete it, since you don't need it anymore. You can then place other macros or user-defined functions in the module so they will be available.

What about formulas? Copy them to the Clipboard and paste them in the module, outside of any procedures defined therein. All you need to do is make sure you preface the formula with an apostrophe, so that the VB Editor thinks you are entering a comment. When you need the formulas at a later time, just go to the VB Editor, open the module, copy the formula, and paste it into the workbook where you need it.

Finally, you could also place your common formulas into AutoCorrect entries. Follow these steps:

  1. Enter your formula as you normally would.
  2. Select the cell containing the formula and press F2. This places Excel in edit mode.
  3. Hold down the Shift key as you use the cursor control keys to select the entire formula, including the equal sign at its very beginning.
  4. Press Ctrl+C. The formula is now on the Clipboard.
  5. Press Esc. You should now be out of edit mode, and the cell with the formula is still selected.
  6. Display the Excel Options dialog box. (In Excel 2007 click the Office button and then click Excel Options. In Excel 2010 or a later version, display the File tab of the ribbon and then click Options.)
  7. At the left side of the screen click Proofing.
  8. Click the AutoCorrect Options button. Excel displays the AutoCorrect dialog box. (See Figure 3.)
  9. Figure 3. The AutoCorrect dialog box.

  10. In the Replace box enter a name you want associated with your formula.
  11. Position the insertion point in the With box.
  12. Press Ctrl+V to paste the formula you copied in step 4.
  13. Click Add. The formula is now safely stored in an AutoCorrect entry.
  14. Close all the dialog boxes on the screen.

You can now use your formula as you would any other AutoCorrect entry. Just type whatever you used in step 9 and then press Enter. The name is replaced with the full formula.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (6135) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Saving Common Formulas.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Making Pictures Show in Word

What are you to do if you can't see all the pictures you know are in your document? The answer may lie in where those ...

Discover More

Self-Deleting Macros

Macros are very powerful, but you may not want them to always be available to a user. Here are some ways you can limit ...

Discover More

Accessing Dependent and Precedent Information

The auditing tools provided in Excel can provide some very helpful information about how your formulas and data are ...

Discover More

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

More ExcelTips (ribbon)

Summing Digits in a Value

Want to add up all the digits in a given value? It's a bit trickier than it may at first seem.

Discover More

Understanding Operators

At the heart of working with Excel is the process of creating formulas that calculate results based on information within ...

Discover More

Filling References to Another Workbook

When you create references to cells in other workbooks, Excel, by default, makes the references absolute. This makes it ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is seven minus 7?

2024-09-25 04:20:54

Philip

@Mike J, a simple "replication" of Veronica's formula using Switch would look like this:

=SWITCH(LEN(B2);
6;"00"& B2;
10;"00"& B2;
11;"0"& B2;
7;"0"& B2;
8;B2;
12;B2;"")

The advantage being that you don't need to worry about parenthesis count when nesting conditions, and also it offers a default value if none of the conditions are met (in this case "").

Note: SWITCH only is available for Excel 2019 and up (including 365 and Web)


2024-09-24 09:27:10

Mike J

@Philip, I also am unfamiliar with the SWITCH function. Could you provide a 'SWITCH()' solution to Veronica Lee's problem?


2024-09-24 05:19:41

Philip

@Veronica Lee, on a side note (not related to storing formulas), the example formula you show would potentially be much simplified if you would use SWITCH instead of IF ... (most people that come to me with questions about Excel are not aware of the existence of this function)


2020-03-11 13:19:31

JDR

Why go all the way to Notepad? Just paste the formulae into an Excel workbook, preceding each formula with an apostrophe (') so it behaves like text. Then you will see a list of all your formula on an Excel tab and can copy and paste whenever wherever.


2019-11-22 13:41:36

Veronica Lee

How would I reference the cell that I'm trying to use the formula / macro on? I created a shortcut, which is genius bc I didn't even know we can do that, but changing the cell reference eliminates this efficient shortcut. Would I have to create a UDF?

=IF(OR(LEN(B2)=6,LEN(B2)=10),"00"&B2,
IF(OR(LEN(B2)=11,LEN(B2)=7),"0"&B2,
IF(OR(LEN(B2)=8,LEN(B2)=12),B2,"")))

Thank you!
<3


2019-10-06 21:29:27

Col Delane

Why on earth would you go to all this trouble to save formulas in a form that is foreign to their native habitat? Isn't the very reason you want to store these formulas is to use them in an Excel spreadsheet? If so, why not save your "formula library" (which can include the use of supporting cells, etc. to provide a complete demonstration) in an Excel spreadsheet where they will actually work as stored?

So, create a Personal Macro Workbook as described. Note that the PMW is nothing more than a bog-standard Excel workbook, but with a magical power to enable macros stored therein to be made available to all open workbooks. But it is still a simple workbook that will operate just like every other Excel workbook, with as many sheets as you want, etc.
Insert a sheet and name it "Formulas" or whatever name you want.
Now use this sheet as a warehouse in which to save all your sample formulas, employing some cataloguing concepts to include some structure, labels, tags, etc. so that you can easily find the formula you want at a later time. Even use different sheets if you like for different types of formulas, or for any other Excel thing you want to keep handy. (My PMW is my always-at-hand Excel toolbox, full of samples covering Data Validation, Conditional Formatting, Defined Names, templates, macros, dates, etc. ) Just simple thinking, really!


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.