Skip to main content

Locate first match that does not begin with

To find the position of the first match that does not begin with a specific string, the MATCH, LEFT and IF functions can do you a favor.

locate first match that does not begin with 1

How to locate the first match that does not begin with “kutools”?

To find the position of the first value that does not begin with “kutools” in the list as shown above, you can use the LEFT and IF functions together to generate a TRUE and FALSE array, in which a TRUE represents a value that does not begin with “kutools”, and a FALSE otherwise. The MATCH function will then match the first TURE in the array to return the position of the first value that does not begin with “kutools”.

Generic syntax

=MATCH(TRUE,IF(LEFT(range,n)<>n_string,TRUE),0)

√ Note: This is an array formula that requires you to enter with Ctrl + Shift + Enter.

  • range: The list from which to return the first value that does not begin with n_string.
  • n: The length of the given n_string.
  • n_string: The string you specified to match the first value that does not begin with it. The length of it should be n. For example, to find the position of the first value that does not begin with “k”. You should set the n argument as 1, and set n_string as “k”.
  • 0: The match_type 0 forces MATCH to perform an exact match.

To find the position of the first value that does not begin with “kutools”, please copy or enter the formula below in the cell E5, and press Ctrl + Shift + Enter to get the result:

=MATCH(TRUE,IF(LEFT(B5:B11,7)<>"kutools",TRUE),0)

Or, use a cell reference to make the formula dynamic:

=MATCH(TRUE,IF(LEFT(B5:B11,7)<>E4,TRUE),0)

locate first match that does not begin with 2

Explanation of the formula

=MATCH(TRUE,IF(LEFT(B5:B11,7)<>E4,TRUE))

  • LEFT(B5:B11,7): The LEFT function returns the leftmost 7 characters of the text strings in the range B5:B11. The results will be in an array like this: {"Kutools";"Kutools";"Ku tool";"Office ";"Tools";"Kutool ";"ExtendO"}.
  • IF(LEFT(B5:B11,7)<>E4,TRUE) = IF({"Kutools";"Kutools";"Ku tool";"Office ";"Tools";"Kutool ";"ExtendO"}<>E4,TRUE): The IF function checks each value in the array whether they match kutools (value in E4) or not. If yes, a FALSE will be returned, otherwise a TRUE will be returned. So, the result will be like this: {FALSE;FALSE;TRUE;TRUE;TRUE;TRUE;TRUE}.
  • MATCH(TRUE,IF(LEFT(B5:B11,7)<>E4,TRUE)) = MATCH(TRUE,{FALSE;FALSE;TRUE;TRUE;TRUE;TRUE;TRUE}): The match_type 0 forces the MATCH function to perform an exact match. The function then returns the position of the first exact TRUE in the array. So, the function will return 3 since the first TRUE is at the 3rd position.

Things to know

  • The formula is not case-sensitive. To perform a case-sensitive match, see the tutorial here.
  • You can change the not equal to operator (<>) to other operators as you need. For example, to locate the first match that begins with a string, you can change it to an equal sign (=).
  • To retrieve the value at the position provide by MATCH, you can add the INDEX function.

Related functions

Excel MATCH function

The Excel MATCH function searches for a specific value in a range of cells, and returns the relative position of the value.

Excel LEFT function

The LEFT function extracts the given number of characters from the left side of a supplied string. For instance, =LEFT("123-234",3) extracts the first 3 characters from the left side of "123-234" and returns "123".

Excel IF function

The IF function is one of simplest and most useful functions in Excel workbook. It performs a simple logical test which depending on the comparison result, and it returns one value if a result is TRUE, or another value if result is FALSE.


Related Formulas

Locate first partial match with wildcards

To get the position of the first partial match that contains specific text string in a range in Excel, you can use a MATCH formula with wildcard characters - the asterisk (*) and question mark (?).

Locate first error

To find the position of the first error in a column or row, the MATCH and ISERROR functions can do you a favor.

Locate first match that does not contain

To find the position of the first match that does not contain a certain string, you can use a formula based on the MATCH, ISNUMBER and SEARCH functions.

Locate maximum value in a range

There are cases when you need to locate the position of the maximum value in a list, table or row in Excel. In this tutorial, we will discuss the approach to accomplish the task with the MAX and MATCH functions.


The Best Office Productivity Tools


Office Tab - Enable Tabbed Reading and Editing in Microsoft Office (include Excel)

  • One second to switch between dozens of open documents!
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Brings Efficient Tabs to Office (include Excel), Just Like Chrome, Edge and Firefox.
Comments (0)
No ratings yet. Be the first to rate!
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations