Function Problems

Excel Formula to Check Whether a Task Contains Sam or Max

Muhammad TalhaMuhammad Talha Dec 2, 2026 868 views

Question details

Create a formula that returns Okay if a task assignment contains Sam or Max, and Not Okay if it contains neither name.

Check Whether a Task Contains Sam or Max in Excel
Product
Microsoft Excel
Device & OS
not provided
Scenario
Check task assignment text in a worksheet and display a status for each row.
Observed behavior
The desired result is Okay when either name appears in the assignment text and Not Okay otherwise.
Before you start

Identify the column containing the task assignment text and an empty column for the results. The example below assumes the first assignment is in cell B2.

Solution 1Recommended

Use SEARCH and OR to check the assignment text

Use this formula to find either name anywhere in the cell, regardless of capitalization.

1
Select the result cell

In Excel, click C2, or choose an empty cell beside the first task assignment.

2
Enter the formula

Enter =IF(OR(ISNUMBER(SEARCH("sam",B2)),ISNUMBER(SEARCH("max",B2))),"Okay","Not Okay") and press Enter. Replace B2 if the assignment text is in a different cell.

3
Fill down

Select C2 and drag the fill handle down the result column to apply the formula to the remaining rows.

Use SEARCH and OR to check the assignment text
Partial matches count: SEARCH is not case-sensitive and matches text within longer words, so a cell containing a word such as Samantha also returns Okay.
WPS Spreadsheet

Check task assignments with a formula in WPS Spreadsheet

Open your worksheet in WPS Spreadsheet and use the same IF, OR, ISNUMBER, and SEARCH formula to label assignments containing Sam or Max.

  1. 1. Open the worksheet: Launch WPS Spreadsheet and use Open to select your workbook.
  2. 2. Choose a result cell: Click C2 next to the first assignment, assuming its text is in B2.
  3. 3. Enter the formula: Type =IF(OR(ISNUMBER(SEARCH("sam",B2)),ISNUMBER(SEARCH("max",B2))),"Okay","Not Okay") and press Enter.
  4. 4. Apply it to other tasks: Drag the fill handle from C2 down the result column, then use File > Save to save the workbook.
Check assignment text for either name without case sensitivity.Open and edit Microsoft Excel XLS and XLSX files.Fill the formula down to evaluate multiple tasks.Use a familiar spreadsheet interface with a free office suite.
microsoft office alternative - wps office

Frequently Asked Questions

Does the formula distinguish between Sam and SAM?

No. SEARCH is not case-sensitive, so Sam, SAM, and sam all match.

What happens if both Sam and Max appear in the same cell?

The formula returns Okay because OR requires at least one of the two SEARCH checks to succeed.

What does the formula return for an empty assignment cell?

It returns Not Okay because neither Sam nor Max is found in the empty cell.

Will the formula match names inside longer words?

Yes. SEARCH finds the specified text anywhere in the cell, so words such as Samantha can also produce Okay.