Function Problems

Excel Formula to Check Whether Text Contains 2020, 2021, or 2022

Muhammad TalhaMuhammad Talha Dec 2, 2026 868 views

Question details

Check whether a cell contains any of the text strings 2020, 2021, or 2022 and return y or n.

Check Whether Excel Text Contains 2020, 2021, or 2022
Product
Microsoft Excel
Device & OS
not provided
Scenario
A worksheet contains text that may include one of several year values.
Observed behavior
The desired formula returns y when any listed year appears in the text and n when none appears.
Before you start

Identify the cell containing the text to check; the examples below use I2. Choose an empty cell for the result and adjust the reference if your text is elsewhere.

Solution 1Recommended

Use SEARCH and OR to check for any listed year

Use this compact formula to return y if I2 contains 2020, 2021, or 2022.

SEARCH looks for each year string in I2. ISNUMBER converts successful matches to TRUE, and OR checks whether at least one match was found.

1
Enter the formula

Select an empty cell, such as J2, and enter =IF(OR(ISNUMBER(SEARCH({"2020","2021","2022"},I2))),"y","n").

2
Check the result

Press Enter. The cell returns y if any listed string appears in I2; otherwise, it returns n.

3
Apply it to other rows

Drag the fill handle from J2 down the column to check the corresponding cells in column I.

Substring matching: The formula finds the year strings anywhere in the cell, including inside longer numbers. In older Excel versions, you may need to confirm the array formula with Ctrl+Shift+Enter.
Check text in WPS Spreadsheet

Find Multiple Years in Text with WPS Spreadsheet

Use SEARCH, ISNUMBER, OR, and IF in WPS Spreadsheet to check a text cell for the listed years and return y or n.

  1. 1. Open your worksheet: Open WPS Spreadsheet and use Open to select your Excel workbook.
  2. 2. Select a result cell: Click an empty cell, such as J2, next to the text in I2.
  3. 3. Enter the formula: Enter =IF(OR(ISNUMBER(SEARCH("2020",I2)),ISNUMBER(SEARCH("2021",I2)),ISNUMBER(SEARCH("2022",I2))),"y","n") and press Enter.
  4. 4. Copy the formula: Drag the cell's fill handle down to check additional rows.
Check for multiple year strings in one formulaOpen and save Microsoft Excel XLSX and XLS filesWork in a familiar spreadsheet interfaceUse WPS Office for free
microsoft office alternative - wps office

Frequently Asked Questions

How can I make the text search case-sensitive?

Replace SEARCH with FIND in the formula. FIND distinguishes uppercase from lowercase, although case makes no difference when searching for digits alone.

Why does SEARCH return an error when a year is missing?

SEARCH returns a #VALUE! error when it cannot find the specified text. Wrapping it in ISNUMBER converts that result to FALSE so OR can test the other years.

Can I return Yes or No instead of y or n?

Yes. Replace the last two arguments of IF with "Yes" and "No", for example: =IF(OR(ISNUMBER(SEARCH({"2020","2021","2022"},I2))),"Yes","No").

Will the formula match a year inside a longer number?

Yes. SEARCH looks for the specified characters anywhere in the cell, so 2020 also matches within a longer string such as 20201.

What if the compact formula does not work in my version of Excel?

In older versions, try confirming the array formula with Ctrl+Shift+Enter. Alternatively, use the separate SEARCH tests shown in the second solution and press Enter normally.