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: Conditionally Highlighting Cells Containing Formulas.

Conditionally Highlighting Cells Containing Formulas

Written by Allen Wyatt (last updated January 23, 2021)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


1

You probably already know that you can select all the cells containing formulas in a worksheet by pressing F5 and choosing Special | Formulas. If you need to keep a constant eye on where formulas are located, then repeatedly doing the selecting can get tedious. A better solution is to use the conditional formatting capabilities of Excel to highlight cells with formulas.

Before you can use conditional formatting, however, you need to create a user-defined function that will return True or False, depending on whether there is a formula in a cell. The following macro will do the task very nicely:

Function HasFormula(rCell As Range) As Boolean
    Application.Volatile
    HasFormula = rCell.HasFormula
End Function

To use this with conditional formatting, select the cells you want checked, and then follow these steps:

  1. With the Home tab of the ribbon displayed, click the Conditional Formatting option in the Styles group. Excel displays a palette of options related to conditional formatting.
  2. Choose New Rule. Excel displays the New Formatting Rule dialog box.
  3. In the Select a Rule Type area at the top of the dialog box, choose Use a Formula to Determine Which Cells to Format. (See Figure 1.)
  4. Figure 1. The New Formatting Rule dialog box.

  5. In the Format Values Where This Formula Is True box, enter "=HasFormula(A1)" (without the quote marks). If the active cell in the range that you selected is not A1, you'll need to modify the formula slightly to reflect whatever cell is active.
  6. Click Format to display the Format Cells dialog box.
  7. Use the controls in the Format Cells dialog box to specify how you want the cells formatted.
  8. Click OK to close the Format Cells dialog box.
  9. Click OK.

Microsoft introduced the ISFORMULA function with Excel 2013. The ISFORMULA function allows you to highlight cells that contain formulas without using a macro. To use this function with conditional formatting, select the cells you want checked, and then follow these steps:

  1. With the Home tab of the ribbon displayed, click the Conditional Formatting option in the Styles group. Excel displays a palette of options related to conditional formatting.
  2. Choose New Rule. Excel displays the New Formatting Rule dialog box.
  3. In the Select a Rule Type area at the top of the dialog box, choose Use a Formula to Determine Which Cells to Format.
  4. In the Format Values Where This Formula Is True box, enter "=ISFORMULA(A1)" (without the quote marks). If the active cell in the range that you selected is not A1, you'll need to modify the formula slightly to reflect whatever cell is active.
  5. Click Format to display the Format Cells dialog box.
  6. Use the controls in the Format Cells dialog box to specify how you want the cells formatted. For instance, you can select a fill color for the cells with formulas.
  7. Click OK to close the Format Cells dialog box.
  8. Click OK.

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 (9900) 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: Conditionally Highlighting Cells Containing 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

Field Calculations in Locked Forms

When adding form fields to a document, you may want some of the fields to be automatically calculated from other fields. ...

Discover More

Unwanted Read-Only Workbook Status

Once a workbook assumes a "read-only" status, it can be a real pain to get that status removed. This tip explains why and ...

Discover More

Identifying Digit-Only Part Numbers Excluding Special Characters

When working with data in Excel, you often need to determine if that data meets criteria that you specify. This tip ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More ExcelTips (ribbon)

Conditional Formats for Odd and Even Columns

Setting up conditional formatting can be challenging under some circumstances, but once set it can work great. Unless, of ...

Discover More

Conditional Formats that Distinguish Blanks and Zeroes

Conditional formatting is a great tool. You may need to use this tool to tell the difference between cells that are empty ...

Discover More

Conditional Formatting Based on Date Proximity

Conditional formatting can be used to draw your attention to certain cells based on what is within those cells. This tip ...

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 2 + 2?

2021-01-25 14:23:54

J. Woolley

You might be interested in the freely available FormulaCellsCF macro in My Excel Toolbox. Here is a simplfied version:

Public Sub FormulaCellsCF()
Const F = "=ISFORMULA(A1)+N(""FormulaCellsCF"")"
For Each FC In ActiveSheet.Cells.FormatConditions
    If FC.Type = xlExpression And FC.Formula1 = F Then
        FC.Delete
        Done = True
    End If
Next FC
If Done Then Exit Sub
With ActiveSheet.Cells.FormatConditions.Add(xlExpression, , F)
    .Interior.Color = &HE6E6E6
End With
End Sub

The complete version is at https://sites.google.com/view/MyExcelToolbox/


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.