Function Problems

Sort Excel 2016 Rows by Most Frequent User with Formulas

Adam DavisAdam Davis Nov 18, 2026 868 views

Question details

Group rows by user and display the users with the most occurrences first using Excel 2016 formulas.

Sort Excel 2016 Rows by Most Frequent User with Formulas
Product
Microsoft Excel 2016
Device & OS
not provided
Scenario
A worksheet contains repeated user names, and its rows need to be grouped by frequency without SORT, SORTBY, or the Data Sort command.
Observed behavior
The desired output keeps each user's rows together, with the most frequent users first and ties resolved by first appearance.
Before you start

Identify the user-name column and the full data range, and leave space for three helper columns and the output. The example uses data in A2:D20001, with a user name in every cell of A2:A20001; adjust all ranges to the actual last row.

Solution 1Recommended

Rank users with helper columns and return rows with INDEX and MATCH

Use Excel 2016-compatible formulas to group rows by user frequency without the Data Sort command.

This example assumes columns A:D contain the source data and column A contains user names. Users with equal frequencies are ordered by their first appearance, and each user's rows retain their original order.

Use the same last row in every full-range reference. Avoid including blank user-name rows, because blanks would be counted as a group.

1
Count each user

In E2, enter =COUNTIF($A$2:$A$20001,A2) and fill it down to E20001. Change 20001 to your actual last data row.

2
Find each user's first appearance

In F2, enter =MATCH(A2,$A$2:$A$20001,0) and fill it down alongside the data.

3
Create a unique row rank

In G2, enter =COUNTIF($E$2:$E$20001,">"&E2)+COUNTIFS($E$2:$E$20001,E2,$F$2:$F$20001,"<"&F2)+COUNTIF($F$2:F2,F2), then fill it down. The rank accounts for frequency, first appearance, and the row's position within its user group.

4
Return the ranked rows

In I2, enter =INDEX(A$2:A$20001,MATCH(ROWS($I$2:$I2),$G$2:$G$20001,0)). Fill the formula across through L2 to return columns A:D, then fill it down for the number of source rows.

Rank users with helper columns and return rows with INDEX and MATCH
Large worksheets may calculate slowly: The helper formulas repeatedly scan the source range. For a large dataset, allow time for recalculation and limit the ranges to the rows actually used.
Sort with formulas in WPS

Group spreadsheet rows by user frequency in WPS Office

Use helper columns and INDEX and MATCH in WPS Spreadsheet to display users in frequency order while preserving their associated row data.

  1. 1. Open the workbook: Open WPS Spreadsheet and use Open to select your Excel workbook. In this example, source data is in A2:D20001 and user names are in column A.
  2. 2. Count user occurrences: In E2, enter =COUNTIF($A$2:$A$20001,A2), then fill the formula down to the last source row.
  3. 3. Identify first appearances: In F2, enter =MATCH(A2,$A$2:$A$20001,0), then fill it down.
  4. 4. Rank the rows: In G2, enter =COUNTIF($E$2:$E$20001,">"&E2)+COUNTIFS($E$2:$E$20001,E2,$F$2:$F$20001,"<"&F2)+COUNTIF($F$2:F2,F2), then fill it down.
  5. 5. Display the grouped data: In I2, enter =INDEX(A$2:A$20001,MATCH(ROWS($I$2:$I2),$G$2:$G$20001,0)). Fill it across through L and down for all source rows. Adjust every range to your actual data.
Group users by occurrence count without using a sort commandOpen and edit Microsoft Excel XLSX filesUse familiar spreadsheet formulas and worksheet controlsWork in a free, lightweight office suite
QA img-9

Frequently Asked Questions

Do these formulas work without SORT or SORTBY?

Yes. The method uses COUNTIF, COUNTIFS, MATCH, INDEX, and ROWS, which are available in Excel 2016. It does not use SORT, SORTBY, or the Data Sort command.

How are users with the same number of rows ordered?

The helper rank places the user who first appears earlier in column A first. Rows for each user remain in their original order.

How do I include more columns in the output?

After entering the INDEX formula in I2, fill it across for as many source columns as needed. Make sure the output area does not overlap the source data or helper columns.

Why is the worksheet calculating slowly?

Each helper formula scans ranges that may contain thousands of rows. Change the range endpoints to the actual last data row rather than including unused rows.

What happens if the user-name column contains blanks?

COUNTIF treats blank user-name cells as a group. Use a source range with a user name in every row, or handle blank rows separately before applying the formulas.