Use a formula to apply conditional formatting

Conditional formatting quickly highlights important information in a spreadsheet. But sometimes the built-in formatting rules don’t go quite far enough. Adding your own formula to a conditional formatting rule gives it a power boost to help you do things the built-in rules can’t do.

For example, let’s say you track your dental patients’ birthdays to see whose is coming up and then mark them as having received a Happy Birthday greeting from you.

In this worksheet, we see the information we want by using conditional formatting, driven by two rules that each contain a formula. The first rule, in column A, formats future birthdays, and the rule in column C formats cells as soon as “Y” is entered, indicating that the birthday greeting has been sent.

In column A future birthdays are formatted in bold red; in column C "Y" for greeting sent is formatted in white text with a green background

To create the first rule:

  1. Select cells A2 through A7. Do this by dragging from A2 to A7.
  2. Then, click Home > Conditional Formatting > New Rule.
  3. In the New Formatting Rule dialog box, click Use a formula to determine which cells to format.
  4. Under Format values where this formula is true, type the formula: =A2>TODAY()

The formula uses the TODAY function to see if the dates in column A are greater than today (in the future). If so, the cells are formatted.

  1. Click Format.
  2. In the Color box, select Red. In the Font Style box, select Bold.
  3. Click OK until the dialog boxes are closed.

The formatting is applied to column A.

To create the second rule:

  1. Select cells C2 through C7.
  2. Repeat steps 2 through 4 above, and enter this formula: =C2="Y"

The formula tests to see if the cells in column C contain “Y” (the quotation marks around the Y tell Excel that this is text). If so, the cells are formatted.

  1. In the Color box, select White. In the Font Style box, select Bold.
  2. Click the Fill tab and select Green.

The formatting is applied to column C.

Try it out

If you want to play around with conditional formatting formulas, here's an Excel Online workbook with another example. You can see the results here, but to see the formatting rules, you'll need to download the workbook to your computer and open it in Excel.

To download the workbook, click the Excel icon in the lower-right corner , save the file to a convenient place on your computer, and then open it.

Download button

More about conditional formatting

 
 
Applies to:
Excel 2013