How to Group Same Names in Excel by Sorting or Summarizing

How-to basics · Updated November 3, 2026

How to Group Same Names in Excel by Sorting or Summarizing

To group identical names together in Excel, select the entire data range, choose Data > Sort, and sort by the name column from A to Z; this moves matching names into adjacent rows without separating them from their other details. If you want one summary line per name instead, create a PivotTable and place the name field in Rows. Before either method, keep a backup and make sure each row of your source data is complete.

What You’ll Need

  • An Excel workbook with a header row and one record per row, such as a customer name in one column and an order, date, or amount in other columns.
  • Microsoft Excel for Microsoft 365 on Windows for the steps below. Excel for Mac and Excel for the web have similar sorting and PivotTable features, though some buttons and dialog layouts can differ slightly.
  • A clear idea of whether you want to rearrange the existing rows, count or total records by name, or simply filter the list to show one name at a time.
  • A saved copy of the workbook if the data is important. Sorting changes the row order, so a copy makes it easy to return to the original arrangement.

Step-by-Step

  1. Check how your data is laid out. Each record should occupy one row, and each type of information should have its own column. For example, put customer names in column A, order dates in column B, and order amounts in column C. Use a descriptive heading such as Customer in the first row. Avoid blank rows or merged cells within the data, because they can make Excel select or sort only part of the list. If names appear in several columns, decide which column defines a match before you begin.
  2. Select the complete data range. Click a cell inside the list. If the data forms one uninterrupted block, Excel will usually recognize its edges when you start a sort. For greater certainty, select every column and row that belongs to the records, including the header row. Do not select only the name column if other columns contain details that must stay with each person. A partial selection can rearrange names while leaving dates or amounts in place, which corrupts the records.
  3. Open the full Sort dialog. On the Windows ribbon, choose Data > Sort. The dialog lets you specify the column and order rather than relying on a quick sort. If prompted, confirm that the data has headers, so Excel treats the heading as a label rather than as a name to sort. In the Sort by list, choose the name column, such as Customer. Under Sort On, leave Cell Values selected. Under Order, choose A to Z, then select OK. Names with the same spelling will now appear together, while all values in their rows move with them.
  4. Add a second sort level if you want order within each name group. Open Data > Sort again, choose Add Level, and set Then by to another column such as Order Date or Amount. Choose the order you want for that second column, then select OK. Excel first groups rows by the name column and then arranges each name’s rows by the secondary field. For instance, sorting by Customer and then Order Date can make each customer’s orders appear together from earliest to latest. Keep the name column as the first level; otherwise the names may not form the groups you expect.
  5. Turn the sorted range into a Table for easier ongoing work, if useful. Select a cell in the data and choose Insert > Table. Check that the displayed range covers all the records and that My table has headers is selected, then select OK. Tables add filter buttons to the headings and generally expand when you add new rows. You can sort from the Customer heading’s filter button as well. A Table does not remove duplicates or permanently lock the order: newly added records may need sorting again.
  6. Use a PivotTable when you want one summary per name. A PivotTable summarizes records instead of merely rearranging them. Select a cell in the source list, choose Insert > PivotTable, check the range, choose New Worksheet, and select OK. In the PivotTable Fields pane, drag the name field to Rows. To count records, drag the name field to Values as well; Excel will commonly label the result Count of Customer. To total sales or another numeric measure, drag that numeric field to Values. The result has one row for each name and a calculated count or total. Check the value field’s settings if Excel chooses an unexpected calculation: open its menu in Values, choose Value Field Settings, and select Count or Sum as appropriate.
  7. Choose the right result for your task and verify it. A sorted list keeps every original row and its details, so use it when you need to inspect individual transactions or edit records. A PivotTable is better for counts and totals, but it is a separate summary and does not replace or merge the source rows. Compare the number of source records with the grouped or summarized results. Spot-check a few names, especially names that appear many times, to confirm that all associated dates and amounts are still correct.
  8. Refresh a PivotTable after changing the source data. If you add or edit source records after building the PivotTable, click inside it and choose PivotTable Analyze > Refresh. If the original source was not an Excel Table and new rows were added outside the selected range, the PivotTable may not include them. In that case, choose PivotTable Analyze > Change Data Source and select the expanded range, or convert the source data to a Table and build the PivotTable from that Table.

If you only need to look at one person or name at a time, use the filter button on the name heading and select the name you want to display. Filtering hides other rows temporarily; it does not sort them into permanent groups or delete them. Also, the Data > Group command is for creating collapsible row or column outlines. It is not the command for finding identical names.

Common Mistakes

Sorting only the names column. This is the most serious error because it disconnects each name from the rest of its record. Select the entire table or range, and if Excel asks whether to expand the selection, choose Expand the selection. If you already sorted just one column, undo immediately with Ctrl+Z on Windows or Command+Z on Mac, then repeat the sort with the whole range selected.

Expecting a sort to create one row per name. Sorting makes duplicate names adjacent but leaves every record in place. If Maria appears on five orders, she will still appear on five rows. Use a PivotTable to count or total those orders. Do not use Remove Duplicates on the full data unless you truly intend to delete records; it can discard valid transactions that happen to share a name.

Assuming names that look alike are identical. A trailing space, a spelling variation, an extra initial, or an accidental character can keep entries apart or create separate summary items. For example, Lee and Lee followed by a space may look the same on screen but be different text. Check questionable values in the source, and standardize them before summarizing. Do not automatically combine similar-looking people if they might be different individuals.

Including blank rows, merged cells, or an incorrect header setting. These can make Excel misread where the records begin and end or treat a heading as a record. Unmerge cells in the data area, remove unnecessary blank rows, and confirm My data has headers in the Sort dialog. Keep headings unique and meaningful so the right field is easy to choose.

Tips

Make a copy of the source sheet before doing a major rearrangement. You can also add a helper column such as Original Order and number the records before sorting. That gives you a way to restore the original sequence later by sorting on that column. Keep the helper column inside the range when sorting so it travels with each record.

For a consistent ongoing process, format the source data as an Excel Table before sorting or creating a PivotTable. Tables make headings easier to identify and help new rows become part of the source. Use clear headings such as Customer, Date, and Amount rather than blank or repeated headings. If a PivotTable should show a count, make sure each source row represents one record; counting the name field counts its nonblank entries, not necessarily unique people across different spellings.

Choose A to Z for names and Z to A if you want the reverse order. If you have surnames and first names in one cell, Excel sorts the complete text, usually by the first character in that cell. To sort by surname accurately, store first and last names in separate columns or create a carefully checked surname column. If names include prefixes or compound surnames, confirm the desired order with your data rules before sorting.

When the desired result is just a temporary view, a filter is often safer than sorting or editing the data. Filtering lets you select one or more names and inspect their matching rows while leaving the underlying records intact. Clear the filter when finished to show all records again. For a report that needs counts or totals, use a PivotTable and give it a clear title so readers understand that it summarizes rather than replaces the detail.

Troubleshooting

Some matching names remain far apart. Check for spaces, spelling differences, punctuation, or different name formats in the source column. Sort the full range again after correcting confirmed errors. If the entries might refer to different people, keep them separate until you can verify their identity rather than combining them based only on a similar spelling.

Names moved but dates or amounts did not. Undo the sort at once with Ctrl+Z on Windows or Command+Z on Mac. Select the entire data range and run Data > Sort again. If you saved or made other changes after the incorrect sort, do not guess at a repair; compare with a backup or the original source, because the row relationships may already be lost.

The sort appears to do nothing or the order looks wrong. Confirm that the correct name column is selected in the Sort dialog and that Order is set to A to Z or Z to A. Check whether a filter is hiding rows, and clear it if you need to inspect the whole list. If the data is in a Table, use its heading filter menu to clear existing sort or filter settings before trying again.

The PivotTable shows Count when you expected a total. Select a value in the PivotTable, open the field menu in the Values area, choose Value Field Settings, and select Sum. If Sum is unavailable or gives an unexpected result, check that the source amounts are numeric values rather than text, and look for blanks or error values. Correct the source data and refresh the PivotTable.

New rows do not appear in the PivotTable. Refresh the PivotTable first. If the new records were added outside its source range, use PivotTable Analyze > Change Data Source to include them. Converting the source range to a Table can make later additions easier to include, but confirm that the PivotTable is based on the Table and refresh after adding records.

The menu looks different on Mac or the web. In Excel for Mac, use the Data tab’s Sort command and Insert tab’s PivotTable command; dialog placement and wording can vary slightly by release. In Excel for the web, sorting and basic PivotTable creation are available, although some advanced settings may be limited compared with Microsoft 365 for Windows. If an option is unavailable in the web app, open the workbook in the desktop application.

Frequently Asked Questions

Does sorting names delete duplicate rows?

No. Sorting only changes row order. Identical names become adjacent, but every record remains. To summarize repeated records, create a PivotTable; to remove records, use a separate deduplication process only after confirming that deleting them is appropriate.

How do I group the same names without losing other columns?

Select the complete data range before sorting, not just the name column. Excel then moves each row as a unit, keeping dates, amounts, and other details connected to the correct name. If prompted, choose Expand the selection.

Can I combine all rows for a name into one row?

A regular sort does not combine rows. A PivotTable can produce one summary row per name with a count or total. It does not preserve every individual detail in that summary; keep the source data if you still need the original records.

How can I count how many times each name appears?

Create a PivotTable, put the name field in Rows, and put that field in Values. Set the Values calculation to Count if Excel does not choose it automatically. Each result then shows the number of nonblank source entries for that name.

Can Excel group names that are spelled slightly differently?

Not reliably as the same person. A spelling difference or extra space may create a separate entry, and similar names may belong to different people. Verify and standardize the source values before grouping; do not merge records based only on resemblance.

Will new names automatically join the right group?

A sorted list does not necessarily resort itself when you add a row, so sort it again. A PivotTable also needs a refresh, and its source must include the new row. An Excel Table can help the source expand as you add records.

Related

Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.

More in How-to basics

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.