Wednesday, October 18, 2017

Use formulas with conditional formatting

Use formulas with 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.

Create conditional formatting rules with formula

For example, let's say a doctors' office wants to track their patients' birthdays to see whose birthday is coming up and then mark them as having received a Happy Birthday greeting from the office.

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.

Sample conditional formatting in Excel

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.

  5. Click Format.

  6. In the Color box, select Red. In the Font Style box, select Bold.

  7. 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.

  3. In the Color box, select White. In the Font Style box, select Bold.

  4. Click the Fill tab and select Green.

    The formatting is applied to column C.

Try it out

You can copy the following table to a worksheet in Excel – be sure to paste it into cell A1. Then, select cells D2:D11, and create a new conditional formatting rule that uses the formula below.

=COUNTIF($D$2:$D$11,D2)>1

When you create the rule, make sure it applies to cells D2:D11. Set a color format to be applied to cells that match the criteria (that is, there is more than one instance of a city in the D column – Seattle and Spokane).

First

Last

Phone

City

Annik

Stahl

555-1213

Seattle

Josh

Barnhill

555-1214

Portland

Colin

Wilcox

555-1215

Spokane

Harry

Miller

555-1216

Edmonds

Jonathan

Foster

555-1217

Atlanta

Erin

Hagens

555-1218

Spokane

Jeff

Phillips

555-1219

Charleston

Gordon

Hee

555-1220

Youngstown

Yossi

Ran

555-1221

Seattle

Anna

Bedecs

555-1222

San Francisco

Need more help?

You can always ask an expert in the Excel Tech Community, get support in the Answers community, or suggest a new feature or improvement on Excel User Voice.

See Also

Copy conditional formatting

Remove conditional formatting

No comments:

Post a Comment