Check if a cell contains text (case-sensitive)

Let's say you want to find text that begins with a standard company prefix, such as ID_ or EMP-, and this text must be in uppercase letters. There are several ways to check if a cell contains text and the case of the text matters to you.

What do you want to do?

Compare one cell to another cell

Function details

Compare one value to a list of values

Function details

Check if part of a cell matches specific text

Function details

Compare one cell to another cell

To do this task, use the EXACT function.

Example

The example may be easier to understand if you copy it to a blank worksheet.

How to copy an example

  1. Create a blank workbook or worksheet.

  2. Select the example in the Help topic.

    Note: Do not select the row or column headers.

    Selecting an example from Help

    Selecting an example from Help

  3. Press CTRL+C.

  4. In the worksheet, select cell A1, and press CTRL+V.

  5. To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Formulas tab, in the Formula Auditing group, click the Show Formulas button.

1

2

3

4

A

Data

BD122

BD123

BD123

Formula

Description (Result)

=EXACT(A2,A3)

Compare contents of A2 and A3 (FALSE)

=EXACT(A3,A4)

Compare contents of A3 and A4 (TRUE)

Note: EXACT is case-sensitive but ignores formatting differences.

Function details

EXACT

Top of Page

Compare one value to a list of values

To do this task, use the EXACT and OR functions.

Example

The example may be easier to understand if you copy it to a blank worksheet.

How to copy an example

  1. Create a blank workbook or worksheet.

  2. Select the example in the Help topic.

    Note: Do not select the row or column headers.

    Selecting an example from Help

    Selecting an example from Help

  3. Press CTRL+C.

  4. In the worksheet, select cell A1, and press CTRL+V.

  5. To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Formulas tab, in the Formula Auditing group, click the Show Formulas button.

1

2

3

4

A

B

List

Cell

Apple

Grape

Orange

Banana

Formula

Description (Result)

=OR(EXACT(B2, A2:A4))

Compares "Grape" to each value in the list (FALSE)

Note: The formula in the example must be entered as an array formula. After copying the example to a blank worksheet, select each formula cell individually. Press F2, and then press CTRL+SHIFT+ENTER. If the formula is not entered as an array formula, the error #VALUE! is returned.

Function details

OR

EXACT

Top of Page

Check if part of a cell matches specific text

To do this task, use the IF, FIND, and ISNUMBER functions.

Note: The FIND function is case-sensitive.

Example

The example may be easier to understand if you copy it to a blank worksheet.

How to copy an example

  1. Create a blank workbook or worksheet.

  2. Select the example in the Help topic.

    Note: Do not select the row or column headers.

    Selecting an example from Help

    Selecting an example from Help

  3. Press CTRL+C.

  4. In the worksheet, select cell A1, and press CTRL+V.

  5. To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Formulas tab, in the Formula Auditing group, click the Show Formulas button.

1

2

3

A

Data

Davolio

BD123

Formula

Description (Result)

=IF(ISNUMBER(FIND("v",A2)),"OK", "Not OK")

Checks to see if A2 contain the letter v (OK)

=ISNUMBER(FIND("BD",A3))

Checks to see if A3 contains BD (TRUE)

The formula above uses the following arguments.

Formula to check for text

Formula to check for text

1. search_for: What you want to check for.

2. to_search: The cell that contains the text that you want to check.

Function details

IF

ISNUMBER

FIND, FINDB

Top of Page

Share Facebook Facebook Twitter Twitter Email Email

Was this information helpful?

Great! Any other feedback?

How can we improve it?

Thank you for your feedback!

×