SEARCH and SEARCHB locate one text string within a second text string, and return the number of the starting position of the first text string from the first character of the second text string.

Important SEARCH is intended for use with languages that use the single-byte character set (SBCS), whereas SEARCHB is intended for use with languages that use the double-byte character set (DBCS). The default language setting on your computer affects the return value in the following way:

The languages that support DBCS include Japanese, Chinese (Simplified), Chinese (Traditional), and Korean.

For more information, see the following Help topics:

Syntax

SEARCH(find_text,within_text,start_num)

SEARCHB(find_text,within_text,start_num)

Find_text is the text you want to find.

Within_text is the text in which you want to search for find_text.

Start_num is the character number in within_text at which you want to start searching.

Remarks

Example 1: SEARCH

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 helpSelecting 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
Statements
Profit Margin
margin
Formula Description (Result)
=SEARCH("e",A2,6) Position of the first "e" in the first string above, starting at the sixth position (7)
=SEARCH(A4,A3) Position of "margin" in "Profit Margin" (8)
=REPLACE(A3,SEARCH(A4,A3),6,"Amount") Replaces "Margin" with "Amount" (Profit Amount)

Example 2: SEARCHB (with your computer set to a default language that supports DBCS)

In the following example:

=SEARCHB(" tokyo to shibuya"," tokyo to shibuya tokyo to shibuya tokyo to shibuya") equals 3

=SEARCH(" tokyo to shibuya"," tokyo to shibuya tokyo to shibuya tokyo to shibuya") equals 2

See also: