bottom
Great ExcelTips!
         
Your e-mail address is safe!
Close Note

Tips.Net > ExcelTips Home > Formatting > Cell Formatting > Conditionally Highlighting Cells Containing Formulas

Conditionally Highlighting Cells Containing Formulas

Summary: You can use conditional formatting for all sorts of things, including the highlighting of cells that contain formulas. This tip explains how you can do this, with the assistance of a short user-defined function. (This tip works with Microsoft Excel 97, Excel 2000, Excel 2002, Excel 2003, and Excel 2007.)

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 if you are using a version of Excel prior to Excel 2007:

  1. Choose Conditional Formatting from the Format menu. Excel displays the Conditional Formatting dialog box.
  2. Make sure the first drop-down list is "Formula Is." (Click here to see a related figure.)
  3. In the formula area, 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.
  4. Click the Format button. Excel displays the Format Cells dialog box. (Click here to see a related figure.)
  5. Use the controls in the Format Cells dialog box to specify how you want the cells formatted.
  6. Click OK to close the Format Cells dialog box.
  7. Click OK to close the Conditional Formatting dialog box.

If you are using Excel 2007 then you should follow these steps, instead:

  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 Highlight Cells Rules and then choose More Rules from the resulting submenu. 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. (Click here to see a related figure.)
  4. 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.
  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.
  7. Click OK to close the Format Cells dialog box.
  8. Click OK.

Tip #3188 applies to Microsoft Excel versions: 97 | 2000 | 2002 | 2003 | 2007


Save Time and Money! Many people need to keep track of employee time, but don't know where to start when it comes to creating a spreadsheet. Here's a way to save time, effort, and money with ready-to-use timesheet templates.
 
Check out Timesheet Templates today!

Helpful Links

Ask an Excel Question
Make a Comment

Tips.Net Home

ExcelTips FAQ
ExcelTips Premium

Learn Access Now

Beauty Tips
Bugs and Pests Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Money Tips
Organizing Tips
Pet Tips
Word2007 Tips
WordTips

Advertise on the
ExcelTips Site

 

Great Info!

Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your e-mail address and click "Subscribe."
     
(Your e-mail address will never be shared with anyone, ever.)