logo
search
Document Editing Problems

How to Sort a Word Index by Last Name

Maira MehtabMaira Mehtab Sep 22, 2026 869 views

Question details

The user needs to sort an existing generated index in a document by last name instead of first name.

Product
Microsoft Word
Device & OS
not provided
Scenario
Reformatting a large, already-generated index to alphabetical order by surname, while preserving layouts like dot leaders, page numbers, and alignment.
Observed behavior
Word's built-in index tools do not offer an automatic way to convert an existing first-name formatted index into last-name order, struggling especially with compound surnames and multiple first names.
Before you start

Make sure you have a blank Excel or spreadsheet workbook open alongside your document to handle the data sorting.

Solution 1Recommended

Use Excel to Separate, Sort, and Reconstruct the Index

Export the index into Excel to leverage its advanced data manipulation tools to separate names, sort them by surname, and paste them back into Word.

Since Word's built-in indexing does not natively convert a first-name index to last-name order after generation, a spreadsheet application is the best workaround. You can split the text, alphabetize it properly, and restore it to your document.

1
Copy the index from Word

Highlight the entire generated index in your Word document, right-click, and select 'Copy'.

2
Paste into Excel and split names

Paste the index into a blank Excel sheet. Select the column containing the names, go to the 'Data' tab, and click 'Text to Columns'. Use spaces as the delimiter to separate first and last names into different columns.

3
Sort the data by last name

Highlight all the newly separated columns. Go to the 'Data' tab, click 'Sort', and choose to sort alphabetically based on the column containing the last names.

4
Recombine the names

In a new empty column, use a formula like =B1&", "&A1 (assuming B is last name and A is first name) to combine the names into a 'Last Name, First Name' format.

5
Restore and format in Word

Copy the newly combined and sorted list, and paste it back into your Word document. You will need to recreate the two-column layout from the 'Layout' tab and reapply paragraph alignment and dot leaders for the page numbers.

Review Compound Surnames: Individuals with compound surnames or multiple first names might not separate correctly during the 'Text to Columns' step. You must manually review and adjust these specific cells in Excel before performing the sort.
Efficient Document Editing

Easily Sort and Format Document Indexes with WPS Office

WPS Office provides seamless integration between WPS Writer and WPS Spreadsheet, making complex index manipulation and data sorting incredibly simple. You can split text, sort lists, and restore complex document layouts without losing formatting.

  1. 1. Transfer index to Spreadsheet: Select the index in WPS Writer, copy it, and paste it into a blank WPS Spreadsheet.
  2. 2. Split the text: Navigate to the 'Data' tab in WPS Spreadsheet and select 'Text to Columns' to divide the first and last names.
  3. 3. Sort and combine: Use the 'Sort' function on the last name column, then use the '&' symbol in a formula to merge the names in the correct order.
  4. 4. Paste and format in Writer: Copy the finalized list back into WPS Writer. Go to the 'Page Layout' tab to set up columns and adjust tab stops for page numbers.
Seamless copy-pasting between WPS Writer and WPS SpreadsheetExcellent compatibility with Microsoft Word (.docx) and Excel (.xlsx) formatsPowerful built-in 'Text to Columns' and data sorting featuresFree and lightweight office suite for all your document needs
microsoft office alternative - wps office

Frequently Asked Questions

Can I force Word to generate the index by last name initially?

Yes, but it requires manual setup. When marking index entries (XE fields) in the document, you must manually type the text in the 'Main entry' box as 'Last Name, First Name'. If the entries are marked this way from the beginning, Word will automatically sort the generated index by last name.

How do I add dot leaders back to my page numbers after sorting?

In Word, select your new index text. Open the 'Paragraph' dialog box, click on 'Tabs' at the bottom left, and set a right-aligned tab stop at your desired margin (e.g., 6.5 inches). Select a dot leader style (usually option 2) and click 'OK'. You can then use the Tab key to push the page numbers to the right with dot leaders.

Why did my page numbers misalign when I pasted from Excel?

When pasting from Excel to Word, the text might inherit spreadsheet formatting or paste as a table. To prevent this, right-click in Word and choose 'Keep Text Only' under Paste Options. Afterwards, manually reapply your column formatting and tab stops.