Excel.Tips.Net Welcome toExcel.Tips.Net

Helpful Links

Tips.Net Home
ExcelTips Home
Ask an Excel Question
Make a Comment

Tips.Net Store

ExcelTips FAQ
ExcelTips Premium

Learn Access Now
Free Printable Forms

Beauty Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Legal Tips
Money Tips
Organizing Tips
Pest Tips
Pet Tips
Wedding Tips
Word2007 Tips
WordTips

Advertise on the
ExcelTips Site

Newest Tips

Removing Borders

Converting to Octal

Filtering Columns for Unique Values

Printing Multiple Worksheets on a Single Page

Changing the Default Font

Creating a Drawing Object

Determining a Value of a Cell

 

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.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (3188) applies to Microsoft Excel versions: 97 | 2000 | 2002 | 2003 | 2007

PivotTables Got You Perplexed? PivotTables for the Faint of Heart shows how you can start using Excel's PivotTable tool right away to spin your data into gold! You discover how easy it really is to crunch the numbers you need to crunch. Uncover the power of creating PivotTables, editing them, formatting them, customizing them, and much more.
 
Check out PivotTables for the Faint of Heart today!