Comparing two lists in Excel using conditional formatting

This lesson describes how to compare two lists in Excel using conditional formatting. For example, let’s take two lists of NFL (National Football League) teams.

To highlight commands in the first list (not the second!), do the following:

  1. Select a range first A1: A18 and give it the name “firstList”.
  2. Then select a range B1: B20 and name it “secondList”.
  3. Now select a range A1: A18.
  4. On the Advanced tab Home (Home) select a team Conditional Formatting > Create Rule (Conditional Formatting > New rule).Comparing two lists in Excel using conditional formatting
  5. Выберите Use a formula to determine which cells to format (Use a formula to determine which cells to format).
  6. Enter the following formula:

    =СЧЕТЕСЛИ(secondList;А1)=0

    =COUNTIF(secondList,А1)=0

  7. Set the formatting style and click OK.Comparing two lists in Excel using conditional formattingResult: The Miami Dolphins and Tennessee Titans are not on the second list.

    Comparing two lists in Excel using conditional formatting

    Explanation:

    • The formula =COUNTIF(secondList;A1) counts the number of commands in the second list that are identical to the command from the cell A1. If COUNTIF(secondList;A1)=0, then the commands from the cell A1 not in the second list. As a result, Excel colors the cell blue.
    • Since we have chosen a range A1: A18 before applying conditional formatting, Excel will automatically copy the formulas to the rest of the cells.
    • So the cell A2 contains the following formula:=COUNTIF(secondList,A2)=0,cell A3:

      =COUNTIF(secondList;A3)=0 etc.

  8. To highlight commands in the second list that are not in the first, select the range B1: B20 and create a new rule using the formula below:

    =СЧЕТЕСЛИ(firstList;B1)=0

    =COUNTIF(firstList,B1)=0

  9. Then set the formatting style (orange fill) and click OKResult: The Denver Broncos, Arizona Cardinals, Minnesota Vikings, and Pittsburgh Steelers are not on the first list.

    Comparing two lists in Excel using conditional formatting

Leave a Reply