Intermediate

How to compare two lists in Excel: COUNTIF, XLOOKUP and conditional formatting

Compare two lists in Excel: who is present and who is missing, what is new, which prices changed — using COUNTIF, XLOOKUP and conditional formatting, plus common traps.

HR has staff lists for October and November. The question: who left and who joined? A warehouse checks an order against the delivery, an accountant matches a bank statement against the books, a manager compares an old and a new price list. The logic is always the same: does each value from the first list exist in the second?

Searching by eye fails even at 20 rows. Below are three methods: flag with a formula, pull the value and compute the difference, and highlight with color.

Книга1 - Excel
—☐✕
B4fx=ЕСЛИ(СЧЁТЕСЛИ($D$2:$D$7;A4)>0;"Stayed";"Left")
ABCDEF
1OctoberStatusNovemberStatus
2Aziz KarimovStayedDilnoza RakhimovaExisting
3Dilnoza RakhimovaStayedAziz KarimovExisting
4Javokhir TuraevLeftSardor AlievExisting
5Malika YusupovaLeftBekzod UsmonovNew
6Sardor AlievStayedNodira SaidovaExisting
7Nodira SaidovaStayedShakhzoda KodirovaNew
8
Готово
Two people left (red), two are new (green) — all with a single COUNTIF

Method 1: COUNTIF — “is it there or not?”

1

Type =СЧЁТЕСЛИ($D$2:$D$7;A2) in B2. The result is how many times Aziz Karimov appears in the November list: 1 means present, 0 means missing.

Книга1 - Excel
—☐✕
B2fx=СЧЁТЕСЛИ($D$2:$D$7;A2)
ABCDE
1OctoberCountNovember
2Aziz Karimov11Dilnoza Rakhimova
3Dilnoza RakhimovaAziz Karimov
4Javokhir TuraevSardor Aliev
5Malika YusupovaBekzod Usmonov
6Sardor AlievNodira Saidova
7Nodira SaidovaShakhzoda Kodirova
8
ГотовоКоличество: 6

2

Always lock the second list’s range with $ (F4). Otherwise it slides down as you fill, and the last rows are checked against only part of the list.

3

Turn the number into a word: =ЕСЛИ(СЧЁТЕСЛИ($D$2:$D$7;A2)>0;"Stayed";"Left") and fill down. For the other direction (who is new?), put the same formula in E2 looking at column A: =ЕСЛИ(СЧЁТЕСЛИ($A$2:$A$7;D2)>0;"Existing";"New").

4

Turn on the filter (Ctrl + Shift + L) and keep only “Left” in column B — your list is ready.

Method 2: XLOOKUP — pull the value and see the difference

1

When you need the value itself, not just yes/no — say, our price versus a supplier’s new price list. Type =ПРОСМОТРX(A2;$E$2:$E$5;$F$2:$F$5;"None") in C2: if the product is in the price list you get its price, otherwise “None”.

Книга1 - Excel
—☐✕
C2fx=ПРОСМОТРX(A2;$E$2:$E$5;$F$2:$F$5;"None")
ABCDEFG
1ProductOursPrice listDiffList itemPrice
2Sugar14 00014 500500Flour420 000
3Flour420 000420 0000Sugar14 500
4Oil22 000None—Rice18 000
5Rice17 00018 0001 000Pasta9 000
6
Готово
Sugar and rice went up, oil is missing from the price list, flour is unchanged

2

Put the difference in D2: =ЕСЛИ(C2="None";"—";C2-B2). A positive number means the price rose, 0 means no change, “—” means the product dropped off the list.

3

XLOOKUP is available in Excel 2021/365. In older versions: =ЕСЛИОШИБКА(ВПР(A2;$E$2:$F$5;2;ЛОЖЬ);"None"). To check presence only: =ЕЧИСЛО(ПОИСКПОЗ(A2;$E$2:$E$5;0)) → TRUE/FALSE.

Method 3: conditional formatting — show the difference in color

1

Select the October list (A2:A7). Главная → Условное форматирование → New Rule...

Книга1 - Excel
—☐✕
ФайлГлавнаяВставкаРазметка страницыФормулыДанныеРецензированиеВидСправка
Вставить
Буфер обмена
Calibri ▾11 ▾
Шрифт
Выравнивание
Общий ▾
Число
Условное форматированиеФорматировать как таблицуСтили ячеек
Стили
ВставитьУдалитьФормат
Ячейки
АвтосуммаСортировка и фильтрНайти и выделить
Редактирование
A2fxAziz Karimov
ABCD
1OctoberNovember
2Aziz KarimovDilnoza Rakhimova
3Dilnoza RakhimovaAziz Karimov
4Javokhir TuraevSardor Aliev
5Malika YusupovaBekzod Usmonov
6
ГотовоКоличество: 4

2

Choose Use a formula to determine which cells to format and enter =СЧЁТЕСЛИ($C$2:$C$7;A2)=0. A2 is the first cell of the selection, without $. Use Формат to pick a red fill.

Книга1 - Excel
—☐✕
A2fxAziz Karimov
ABCD
1OctoberNovember
2Aziz KarimovDilnoza Rakhimova
3Dilnoza RakhimovaAziz Karimov
4Javokhir TuraevSardor Aliev
5
ГотовоКоличество: 3

3

Click OK — names missing from November turn red. The color is live: change a list and the highlighting updates by itself.

Книга1 - Excel
—☐✕
fx
ABCD
1OctoberNovember
2Aziz KarimovDilnoza Rakhimova
3Dilnoza RakhimovaAziz Karimov
4Javokhir TuraevSardor Aliev
5Malika YusupovaBekzod Usmonov
6Sardor AlievNodira Saidova
7Nodira SaidovaShakhzoda Kodirova
8
Готово

Pro level: get the list of differences with one formula

  • Only those who left (Excel 365): =ФИЛЬТР(A2:A7;СЧЁТЕСЛИ(D2:D7;A2:A7)=0) — the result spills down, no filter needed.
  • Compare on two columns (e.g. name and position must both match): =СЧЁТЕСЛИМН($D$2:$D$7;A2;$E$2:$E$7;B2).
  • Present in both lists: select both ranges with Ctrl → Условное форматирование → Highlight Cells Rules → Duplicate Values. If neither list has internal repeats, the colored cells are the common ones.
  • Row-by-row comparison (two columns in the same order): =A2=B2 or =СОВПАД(A2;B2). UI way: select both columns and press Ctrl + \ — Excel selects the cells that differ (Go To Special → Row Differences).

Try it in the simulator

Type =ЕСЛИ(СЧЁТЕСЛИ($C$2:$C$7;A2)>0;"Stayed";"Left") in B2 and fill down to B7. Then type =ЕСЛИ(СЧЁТЕСЛИ($A$2:$A$7;C2)=0;"New";"") in D2 to find who joined in November.

Книга1 - Excel
—☐✕
Буфер обмена
Шрифт
Выравнивание
Число
Стили
Ячейки
Редактирование
✕✓fx
ABCDEFGHIJKLMNOPQRSTUVWX
1OctoberStatusNovemberNew?
2Aziz KarimovDilnoza Rakhimova
3Dilnoza RakhimovaAziz Karimov
4Javokhir TuraevSardor Aliev
5Malika YusupovaBekzod Usmonov
6Sardor AlievNodira Saidova
7Nodira SaidovaShakhzoda Kodirova
8
9
10
11
Лист1
Готово

Has ExcelLab been useful?

Support the project and help us release new lessons and exercises.

Support us
Previous

143 / 154