Excel sorted the names but left the amounts behind
After a sort, the grand total still matches, but customers now have the wrong balances beside their names. Can you put the amounts back with the right people?

- If a sort just broke the rows, use Undo. If that is unavailable, look for a correct earlier copy or version history for a file stored in OneDrive or SharePoint.
- The sort range must include every field belonging to a record. Blank separators and columns added outside an Excel table can leave related information behind.
- SORTBY can create a separate ordered list while preserving the source order. Check customer and amount against each order ID; an unchanged total does not establish that the records are intact.
Undo the bad sort before trying another order
If Excel moved customer names without their amounts, reverse the bad operation first. Sorting the names in descending order will not reconstruct their original sequence. Sorting the entire range now will move the incorrect combinations together.
In Windows desktop Excel, press Ctrl+Z or use Undo immediately after the mistake. If other edits followed, inspect the Undo list before rolling them back. Saving does not automatically make an edit irreversible: Microsoft says saved changes can still be undone within the available undo history and limits. Running a macro can clear that history. See the Undo documentation for those conditions.
When Undo is unavailable, find a version with correct records. For a Microsoft 365 file stored in OneDrive or SharePoint, select the file title, open Version History and inspect an earlier version in its own window. Restore after checking the records. This version history feature depends on cloud storage; it is not automatically available for every workbook saved only on a PC.
Suppose the mistake happened before lunch and new orders were entered afterward. Preserve a copy of the current workbook before replacing it with an earlier version. The new orders will need reconciling against the restored file. An original export or previously sent order report may also provide the missing relationships.
How a correct total hides incorrect customers
A customer is the sorting key; the order is the record that should move. An Excel user's question describes the same problem with city names: alphabetizing the city column did not carry the corresponding information along. A visibly alphabetical list can still contain incorrect records.
Consider this illustrative ledger in A1:D4, with headings in row 1. The dollar amounts are example data.
| Order ID | Customer | Region | Amount (USD) |
|---|---|---|---|
| O103 | Cedar | West | 300 |
| O101 | Alder | East | 100 |
| O102 | Birch | West | 200 |
Sort only B2:B4 alphabetically and the first record becomes O103, Alder, West, $300. Alder originally belonged to O101, East, $100. The amounts never moved, so their total remains $600. There are still three rows. Neither check exposes the wrong customer assignment.
With complete records included, the correct order is O101/Alder/$100, O102/Birch/$200, then O103/Cedar/$300, with each region accompanying its order. Nothing has been added or subtracted. Comparing these combinations against the source checks something a grand total cannot.
Select the records, then choose the sort key
For this ledger, select A1:D4 and open Data → Sort. Choose Customer, Cell Values and A to Z. Enable My data has headers so the heading is excluded. The selected range contains all four fields even though only one field determines the order.
If you started with a single column and Excel displays its warning, choose Expand the selection to include adjacent related data. Continuing with the current selection can detach that column from its original records. Microsoft documents this in sorting a range within a larger range. The warning depends on detection; its absence is not proof that your intended range was selected.
A wide ledger needs its rightmost fields too. Selecting A:D omits delivery instructions in J, even if those instructions describe the same orders. Selecting the entire worksheet can instead pull in unrelated material. Define the rectangle belonging to this dataset, including its final record.
Blank separators complicate automatic detection. If column E is empty and delivery notes sit in F, Excel has less information that this is one continuous dataset. Microsoft's worksheet organization guidance recommends keeping blank rows and columns outside related data, and using them between separate datasets. One missing phone number is not the same layout as a wholly empty spacer column.
Keep delivery notes beside the other order fields within the selected range. Use borders or column widths for visual spacing. A report title above the headings and a manually entered grand total below the orders are not customer records. Reveal hidden fields before choosing the range so an order ID or assignment column is not overlooked.
Keep new columns inside the Excel table
For a growing ledger, select the data and use Home → Format as Table. Choose a style, check the actual range in the dialog and specify whether it has headings. These are the table creation steps; manually coloring cells does not define the same object.
Sorting through the Customer header acts on records within that table. A note outside its boundary does not become part of the record because it shares the same background color. Converting already scrambled data into a table will also preserve the current incorrect combinations.
Consider a four-column table receiving a new batch with a fifth column for delivery instructions. Microsoft says that when pasted new rows have more columns than the existing table, the extra columns are not included automatically. Use Table Design → Resize Table to include the full range. The table resizing documentation describes this specific paste condition.
If you already sorted while those instructions were outside the table, restore the correct ID-to-note relationships before resizing. Otherwise you are simply adding the misplaced notes to the table as they now stand.
Make a sorted view without moving the source
If operations needs arrival order while accounts needs an alphabetical list, create a separate result. SORTBY is available in Excel for Microsoft 365, Excel 2024 and Excel 2021. For the example ledger, put headings in G1:J1 and enter this in G2:
=SORTBY(A2:D4,B2:B4,1) A2:D4 supplies all four fields. B2:B4 supplies the customer sorting key, and 1 requests ascending order. The three-by-four result occupies G2:J4 without rearranging the source. Returning only B2:B4 would produce names without the accompanying order information. This fixed-range example needs longer references when another record is added.
A source table allows structured references that follow added and removed rows. With a table named Orders and a heading named Customer, use =SORTBY(Orders,Orders[Customer],1). Substitute your actual table and heading names. Keep the full source record in the first argument and its sorting field in the second.
Place the output formula outside the table, with room for its result. A blocked output area can produce #SPILL!. Edit the formula in its top-left cell; change a customer's amount in the source ledger. Microsoft's spilled array documentation explains these output restrictions.
Do not attach handwritten status notes to positions beside the result. If a customer name changes and the formula rearranges its output, a note outside that output does not follow the customer. Store the status in the source record and return that field as well. The sorted list can then serve as a lookup view while edits stay attached to order IDs in the original ledger.
Recovering record relationships and original order
After sorting the example, check that O101 still means Alder, East and $100. Repeat for O102 and O103. For a real workbook, reconcile records by ID against a trusted copy, including newly added fields and the final rows. A few correct examples at the top do not establish that the rest were repaired.
If every ID still carries its original details, only the sequence has changed. A fixed arrival number saved before sorting can restore that sequence, provided it moved with each complete record. A value representing the current worksheet row is not an independent record of the earlier order.
If only the customer column moved, sorting the ledger by its remaining IDs will not repair it. O101 will retain the wrong customer wherever the row goes. Use the correct earlier record to recover the association. Names alone can be ambiguous when customers share a name or one customer has several orders.
For example, two orders from Alder could legitimately carry different delivery addresses. Replacing both addresses with the first one found under that customer name would introduce another error. Match each order to its own source record, including any instructions added after the earlier copy was saved.
Without a correct copy or another source of order details, the $600 total cannot tell you which customer owes which amount. Reconcile against the original orders before using the affected rows for customer statements. Resume sorting only after the relationships have been recovered.