How to Find the Maximal or Minimal String Based on Alphabetic Order

This post will explain that how to get the maximal or minimal string based on the alphabetic order from a range of cells in Excel. You will learn that how to use the Excel Functions to find or extract the Maximal string or Minimal string based on alphabetic order from a specified range of cells.

Assuming that you have a list of data that contains string values in the range B1:B5.

Finding Maximal String

If you want to get the maximal string or largest string based on the alphabetic order, you can use the MATCH function and COUNTIF function to combine with the INDEX function to create the below Excel Array Formula to achieve the result.

{=INDEX(B1:B5,MATCH(0,COUNTIF(B1:B5,">"&B1:B5),)) }

You can enter the above formula into the formula box of Cell C1, then press Ctrl + Shift + Enter shortcuts to change the formula as Array formula. You will see that the maximal string will be extracted.

find maximal string1

 Let’s see how this formula works:

=COUNTIF(B1:B5,”>”&B1:B5)

The COUNTIF function will count the number of cells in range B1:B5 that meet a given criteria. And this criteria is that each value in the range B1:B5 is compared with other values in the same range, and then get the number of text values that is greater than comparing each text value in range B1:B5 with other text values in B1:B5, then counting the number of other text values that is greater than the value.

For example, In range B1:B5, there are 3 text values that is greater than “Excel” text in Cell B1, then the COUNTIF function will return the number 3. To get the number of the other text values based on this criteria, we need to consider to use the array formula.  Just see the below screenshot:

find maximal string countif function1

Note: if no any text values are greater than the value, it will return the number 0. And this text value is what we are looking the maximal text value.  So we can use this formula combining with the MATCH function to the number 0 in the array list that returned by the COUNTIF function and returns the position of number 0.

{=MATCH(0,COUNTIF(B1:B5,”>”&B1:B5),)}

This function will use the MATCH function to get the position of the number 0, then pass this index value to the INDEX function to get the maximal text value in range B1:B5.

find maximal string match function1

Find Minimal String

If you just want to find the minimal String, just change the criteria from the above COUNTIF function, so you can write down the following array formula:

{=INDEX(B1:B5,MATCH(0,COUNTIF(B1:B5,"<"&B1:B5),)) }

find minmal string1


Related Functions

  • Excel INDEX function
    The Excel INDEX function returns a value from a table based on the index (row number and column number)The INDEX function is a build-in function in Microsoft Excel and it is categorized as a Lookup and Reference Function.The syntax of the INDEX function is as below:= INDEX (array, row_num,[column_num])…
  • Excel MATCH function
    The Excel MATCH function search a value in an array and returns the position of that item.The syntax of the MATCH function is as below:= MATCH  (lookup_value, lookup_array, [match_type])….
  • Excel COUNTIF function
    The Excel COUNTIF function will count the number of cells in a range that meet a given criteria. This function can be used to count the different kinds of cells with number, date, text values, blank, non-blanks, or containing specific characters.etc.= COUNTIF (range, criteria)…
Related Posts
VLOOKUP From Another Sheet Not Working
vlookup from another sheet not working3

In the previous post, you should know that how to fix or remove the #N/A error when using VLOOKUP formula to lookup value from another sheet. And this post will show you reasons why your VLOOKUP formula is not working ...

Case Sensitive Lookup with SUMPRODUCT and EXACT

Today, we will show you how to use SUMPRODUCT and EXACT to perform a case sensitive exact match. In this article, we provide a simple example to calculate bonus for employees whose names are case-sensitive. If you meet similar scenarios ...

Basic Usage of INDEX & MATCH – Case Sensitive Lookup

In Excel, INDEX function and MATCH function are often used together for retrieving data from a particular position. MATCH function is one of Excel lookup & reference functions that can perform approximate match or exact match by setting different match ...

Basic Rates Calculation by VLOOKUP Based on Weight Band

Microsoft Excel provides many functions that can execute logical test, search data, return current date and something else. They are very useful in daily work. And Excel VLOOKUP function is one of Excel most frequently used functions. It belongs to ...

Basic Grade Calculation by VLOOKUP Function – Approximate Match

In Excel, except combination INDEX+MATCH, we can also apply other functions to search data, for example VLOOKUP function. Like MATCH function, VLOOKUP function is one of Excel lookup & reference functions that can perform approximate match or exact match by ...

Basic Discount Calculation with VLOOKUP Function

In Excel, except combination INDEX+MATCH, we can also apply other functions to search data, for example VLOOKUP function. Like MATCH function, VLOOKUP function is one of Excel lookup & reference functions that can perform approximate match or exact match by ...

Basic Usage of INDEX & MATCH – Exact Match
Basic Usage of INDEX & MATCH - Exact Match 1&2

In Excel, INDEX function and MATCH function are often used together for returning value or cell reference or range reference from specified position. And MATCH function is one of Excel lookup & reference functions that can perform approximate match or ...

Basic Usage of INDEX & MATCH – Approximate Match

In Excel, INDEX function and MATCH function are often used together for returning value or cell reference or range reference from specified position. And MATCH function is one of Excel lookup & reference functions that can perform approximate match by ...

Approximate Match with Multiple Criteria by INDEX & MATCH
Approximate Match with Multiple Criteria by INDEX & MATCH 1 & 2

In Excel, INDEX function and MATCH function are often used together for returning data from specific position. And MATCH function is one of Excel lookup & reference functions that can return approximate value by setting match type. Above all, through ...

How to Count Cells Not Equal to One of Many Things in Excel
count cells not equal many things10

This post will guide you how to count the number of cells that are not equal to many things in a given range cells using a formula in Excel 2013/2016. You can easily to count cells not equal to a ...

Sidebar