Skip to content
Free Excel Tutorials
  • Home
  • Excel For Beginners
  • Excel Intermediate
  • Advanced Excel For Experts

Data Analysis

  • How To Filter Data in Excel
  • Everything about Charts in Excel
  • How to create Gauge Chart in Excel
  • How To Sort One Column or Multiple Columns in Excel
  • How to Create Area Chart in Excel

References

  • How to create dynamic named range with OFFSET in Excel
  • LOOKUP function: Description, Usage, Syntax, Examples and Explanation
  • How to get address of first cell in range in Excel
  • CHOOSE function: Description, Usage, Syntax, Examples and Explanation
  • Find Closest Match in Excel Using INDEX, MATCH, ABS and MIN functions

Data Validations

  • Excel Data validation exists in list
  • Excel Data validation date in next 30 days
  • Excel Data validation specific characters only
  • How To Create Drop-down List in Excel
  • Excel Data validation must contain specific text

Basic text sort formula in Excel

by

To dynamically sort text values in alphabetical order, you can use use a formula based on the COUNTIF function.

Formula

=COUNTIF(range,"<="&A1)

Explanation

In the example shown, the formula in C5 is:

=COUNTIF(countries,"<="&B5)

where “countries” is the named range B4:B13

How this formula works

This formula uses the “greater than or equal to” operator with text, something you might not have tried before. When Excel compares text, it decides which value is “greater” than another based rules that follow the ASCII numbering scheme.

Inside COUNTIF, the range argument is supplied as the named range “countries” (B4:B13), and criteria is supplied as “less than or equal to” the value in C5. In each row, COUNTIFS returns the number of values that are less than or equal to the current value, which creates a sequential list of numbers (i.e. a rank) in the helper column.

Handling duplicates

If the data contains duplicate text values, the sequence of sort numbers will also contain duplicates, which will cause problems if you are trying to retrieve values with the INDEX function. To work around this problem, you can use a variation of the formula that increments duplicates with a second COUNTIF:

=COUNTIF(countries,"<"&B5)+COUNTIF($B$5:B5,B5)

Note the logical operator in the first COUNTIF function has been adjusted, and the range in the second COUNTIF function is an expanding reference.

Listing sorted values

The helper column can be used used to retrieve sorted values by rank. In E5, the formula used to retrieve values is:

=INDEX(countries,MATCH(ROWS($E$5:E5),helper,0))

This is an INDEX and MATCH formula that uses an expanding reference to generate sequential numbers, which are fed into MATCH as lookup values. MATCH figures out where each number exists in the data, and INDEX retrieves the value at that position. See this page for a more detailed explanation.

Post navigation

Previous Post:

How to calculate project complete percentage in Excel

Next Post:

Popularly Used Excel Functions and their examples

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Learn Basic Excel

Ribbon
Workbook
Worksheets
Format Cells
Find & Select
Sort & Filter
Templates
Print
Share
Protect
Keyboard Shortcuts

Categories

  • Charts
  • Data Analysis
  • Data Validation
  • Excel Functions
    • Cube Functions
    • Database Functions
    • Date and Time Functions
    • Engineering Functions
    • Financial Functions
    • Information Functions
    • Logical Functions
    • Lookup and Reference Functions
    • Math and Trig Functions
    • Statistical Functions
    • Text Functions
    • Web Functions
  • Excel VBA
  • Excel Video Tutorials
  • Formatting
  • Grouping
  • Others

Logical Functions

  • IF function: Description, Usage, Syntax, Examples and Explanation
  • Invoice status with nested if in Excel
  • How to use Excel AND Function
  • IF, AND, OR and NOT Functions Examples in Excel
  • AND function: Description, Usage, Syntax, Examples and Explanation

Date Time

  • Calculate years between dates in Excel
  • TIME function: Description, Usage, Syntax, Examples and Explanation
  • How to calculate percent of year complete in Excel
  • EOMONTH function: Description, Usage, Syntax, Examples and Explanation
  • Get days before a date in Excel

Grouping

  • Calculate conditional mode with criteria in Excel
  • Categorize text with keywords in Excel
  • Map text to numbers in Excel
  • How to randomly assign data to groups in Excel
  • Group numbers with VLOOKUP in Excel

General

  • How to calculate percent change in Excel
  • Cell References: Relative, Absolute and Mixed Referencing Examples
  • Delete Blank Rows at Once in Excel
  • How to create dynamic named range with INDEX in Excel
  • How to generate random date between two dates in Excel
© 2025 xlsoffice . All Right Reserved. | Teal Smiles | Abbreviations And Their Meaning