Features of !SEMTools
↑ Navigate Excel tasks and !SEMTools add-in features ↑

Find cells by several conditions in Excel

, creator of !SEMToolsUpdated 8 min readTopics: Data analysis, Excel functions
Find cells containing, beginning or ending with values from a list in Excel
Three lists, three checks: «pro, ultra» anywhere in the cell, «buy, cheap» at the start, «pro, sale» at the end.

Finding several values in Excel in one go is not a trivial task. The AutoFilter’s Custom Filter dialog accepts at most two conditions. They can be completely different, but there are only two of them. And if you want 3, 4, 5 or more search conditions, it doesn’t fit.

Usually this is needed for text criteria: equals, begins with, contains, ends with. For numbers, two conditions (“greater than” and “less than”) are usually enough. Let’s look at the ways to find cells by several conditions. This page is part of the article on how to find cells in Excel.

Find several words or phrases in cells

If the conditions are whole words rather than any substrings, see the separate articles: find words in cells and find phrases in Excel. Words need different logic: “cat” shouldn’t match “category”.

Find several values by exact match

To check whether a cell equals one of several values, a simple comparison in an array formula does the job. The list of values is in E1:E4:

=OR(A1=$E$1:$E$4)
Equals one of the values
B2=OR(A2=$E$2:$E$5)
ABCDE
1CityIn the list?List
2ParisTRUE=OR(A2=$E$2:$E$5)London
3parisTRUE=OR(A3=$E$2:$E$5)Paris
4MadridFALSE=OR(A4=$E$2:$E$5)Berlin
5Rome FALSE=OR(A5=$E$2:$E$5)Rome

“paris” matches because the comparison ignores case. “Rome ” with a trailing space doesn’t — clean such data with TRIM first.

How it works:

  • A1=$E$1:$E$4 compares A1 with every value in the list and returns an array of TRUE and FALSE;
  • the dollar signs make the reference absolute, so it doesn’t shift when you fill the formula down;
  • the OR function returns TRUE if at least one comparison is TRUE.

This formula is especially useful for checking whether a value belongs to a list of allowed values. The comparison ignores case; if case matters, use the EXACT function instead: =OR(EXACT(A1,$E$1:$E$4)).

Find cells by partial match: contains, begins, ends

If you need a partial match rather than an exact one, the formula depends on the type of search. The functions SEARCH and FIND work for “contains”. The only difference between them is that FIND is case-sensitive and SEARCH is not.

Contains any of the values

=COUNT(SEARCH($B$1:$B$10,A1))>0
Contains any of the values
B2=COUNT(SEARCH($D$2:$D$4,A2))>0
ABCD
1TextResultList
2monthly reportTRUE=COUNT(SEARCH($D$2:$D$4,A2))>0report
3plan BTRUE=COUNT(SEARCH($D$2:$D$4,A3))>0plan
4project reportTRUE=COUNT(SEARCH($D$2:$D$4,A4))>0task
5taskbarTRUE=COUNT(SEARCH($D$2:$D$4,A5))>0
6budgetFALSE=COUNT(SEARCH($D$2:$D$4,A6))>0

SEARCH returns a position for each value found and an error for the rest; COUNT counts the positions. “taskbar” contains “task”, so it matches.

  • SEARCH($B$1:$B$10,A1) looks for each value of the list in A1 and returns an array of positions and errors;
  • COUNT counts the numbers in it, that is, the values found;
  • >0 returns TRUE if at least one value was found.

Important: the list must not contain empty cells. SEARCH finds an empty string in any text, and the formula returns TRUE for every cell. The same approach lets you find uppercase letters or find numbers in text cells.

Begins with any of the values

To check whether a cell begins with at least one of the values in the list, compare the beginning of the cell of the right length with each value:

=OR(LEFT(A1,LEN($B$1:$B$10))=$B$1:$B$10)
Begins with any of the values
B2=OR(LEFT(A2,LEN($D$2:$D$4))=$D$2:$D$4)
ABCD
1TextResultList
2monthly reportFALSE=OR(LEFT(A2,LEN($D$2:$D$4))=$D$2:$D$4)report
3plan BTRUE=OR(LEFT(A3,LEN($D$2:$D$4))=$D$2:$D$4)plan
4project reportFALSE=OR(LEFT(A4,LEN($D$2:$D$4))=$D$2:$D$4)task
5taskbarTRUE=OR(LEFT(A5,LEN($D$2:$D$4))=$D$2:$D$4)
6budgetFALSE=OR(LEFT(A6,LEN($D$2:$D$4))=$D$2:$D$4)

LEFT cuts as many characters as each value has and compares them. “project report” doesn’t begin with a value from the list.

LEN takes the length of each value, LEFT cuts that many characters from A1, and the comparison checks whether they match. For example, with the list “report”, “plan”, “task”, the cell “Report on project” returns TRUE, and “project report” returns FALSE.

Ends with any of the values

The same logic with RIGHT:

=OR(RIGHT(A1,LEN($B$1:$B$10))=$B$1:$B$10)
Ends with any of the values
B2=OR(RIGHT(A2,LEN($D$2:$D$4))=$D$2:$D$4)
ABCD
1TextResultList
2monthly reportTRUE=OR(RIGHT(A2,LEN($D$2:$D$4))=$D$2:$D$4)report
3plan BFALSE=OR(RIGHT(A3,LEN($D$2:$D$4))=$D$2:$D$4)plan
4project reportTRUE=OR(RIGHT(A4,LEN($D$2:$D$4))=$D$2:$D$4)task
5taskbarFALSE=OR(RIGHT(A5,LEN($D$2:$D$4))=$D$2:$D$4)
6budgetFALSE=OR(RIGHT(A6,LEN($D$2:$D$4))=$D$2:$D$4)

Now “monthly report” and “project report” match; “taskbar” doesn’t end with “task”.

Now “project report” returns TRUE. You’ll find formulas built on SEARCH for this task on the web, but they fail when the value occurs in the text more than once, as in “reportreport”. The RIGHT version doesn’t have this problem.

In Excel 2019 and earlier, all these formulas are entered with Ctrl+Shift+Enter. In Excel 365 and 2021, just press Enter.

Checking a whole range for several values

To find out whether a range contains at least one of several values, COUNTIF with a list as its criteria does the job:

=SUMPRODUCT(COUNTIF($A$1:$A$100,$B$1:$B$10))>0

COUNTIF supports wildcards, so the same formula finds cells that begin or end with any of the values:

=SUMPRODUCT(COUNTIF($A$1:$A$100,$B$1:$B$10&"*"))>0
=SUMPRODUCT(COUNTIF($A$1:$A$100,"*"&$B$1:$B$10))>0
Does a range contain any of the values
F2=SUMPRODUCT(COUNTIF($A$2:$A$5,$C$2:$C$4))>0
ABCDEF
1DataListCheckResult
2monthly reportreportequals anyFALSE=SUMPRODUCT(COUNTIF($A$2:$A$5,$C$2:$C$4))>0
3plan Bplanbegins with anyTRUE=SUMPRODUCT(COUNTIF($A$2:$A$5,$C$2:$C$4&"*"))>0
4taskbartaskends with anyTRUE=SUMPRODUCT(COUNTIF($A$2:$A$5,"*"&$C$2:$C$4))>0
5budget

No cell equals a list value exactly, so the first check is FALSE. “plan B” and “taskbar” begin with list values, and “monthly report” ends with one.

The difference from the previous formulas is that they check a whole range at once, not each cell separately. You can do the same with VLOOKUP or XLOOKUP, but COUNTIF is shorter.

Filtering by several conditions in Excel 365

In Excel 365, the FILTER function returns all the rows that meet any number of conditions. Multiply the conditions for AND, add them for OR. All cells that contain both “red” and “sofa”:

=FILTER(A2:A100,ISNUMBER(SEARCH("red",A2:A100))*ISNUMBER(SEARCH("sofa",A2:A100)))
FILTER with AND
C2=FILTER(A2:A6,ISNUMBER(SEARCH("red",A2:A6))*ISNUMBER(SEARCH("sofa",A2:A6)))
ABC
1ProductResult
2Red sofaRed sofa=FILTER(A2:A6,ISNUMBER(SEARCH("red",A2:A6))*ISNUMBER(SEARCH("sofa",A2:A6)))
3Blue couch
4Red chair
5Grey sofa bed
6Red Couch

Multiplying the conditions is AND: a row stays only if both words are found.

And all cells that contain “sofa” or “couch”:

=FILTER(A2:A100,ISNUMBER(SEARCH("sofa",A2:A100))+ISNUMBER(SEARCH("couch",A2:A100)))
FILTER with OR
C2=FILTER(A2:A6,ISNUMBER(SEARCH("sofa",A2:A6))+ISNUMBER(SEARCH("couch",A2:A6)))
ABC
1ProductResult
2Red sofaRed sofa=FILTER(A2:A6,ISNUMBER(SEARCH("sofa",A2:A6))+ISNUMBER(SEARCH("couch",A2:A6)))
3Blue couchBlue couch
4Red chairGrey sofa bed
5Grey sofa bedRed Couch
6Red Couch

Adding the conditions is OR. SEARCH ignores case, so “Red Couch” is found too.

In older versions, the Advanced Filter (Data → Advanced) can do something similar: it takes a criteria range, where each row is an OR condition and each column in a row is an AND condition, with wildcards like “*sofa*”.

Find cells by several conditions with !SEMTools

The formulas above handle the task well. But if you solve such tasks often, finding a saved copy of the formula or typing it by hand, filling it down and cleaning up afterwards slows you down a lot.

I’ve been in this situation many times myself, so I decided to automate it and made a few convenient procedures. And then many more for other tasks, and that’s how a whole Excel add-in was born.

With !SEMTools, you search by several conditions without complex formulas: select the range, enter the list of values and choose the type of match (equals, contains, begins with, ends with). The add-in returns TRUE or FALSE next to the values that meet the conditions, right in place:

How to run it:

  1. Select the column you want to check.
  2. On the !SEMTools tab, open FIND → Cells → By custom criteria list and pick Containing, Beginning with or Ending with.
  3. For the last two, choose Input range... and select the cells with your values, or Prepositions to use the built-in list.
  4. Each cell gets TRUE or FALSE in place, ready for a filter.
Find cells that start or end with a preposition in Excel
Handy for catching broken search queries such as «shoes for» or «cheap flights to».

See also:

Find cells that equal, contain, begin or end with any value from a list, right in place, without array formulas.
!SEMTools solves this and hundreds of other tasks in a couple of clicks!

Summary: how to find cells by several conditions

I hope you found what you were looking for on this page and were able to find cells by several conditions. OR with a comparison handles exact matches, SEARCH, LEFT and RIGHT handle partial ones, COUNTIF checks a whole range, and FILTER in Excel 365 returns the matching rows. For regular searches by long lists, the !SEMTools procedures are faster.