How to Sort Excel Records with Multiple Diagnosis Codes in WPS Office Spreadsheets
Question details
The user needs to keep patient information associated with multiple diagnosis codes when sorting a worksheet that has blank rows and repeated patient data.
- Product
- WPS Office Spreadsheets
- Device & OS
- not provided
- Scenario
- The user is working with patient records where one patient has multiple diagnosis code rows, and the patient identifier appears only on the first row or in blank/repeated cells.
- Observed behavior
- Sorting the worksheet without first filling the patient identifier down can separate diagnosis codes from the correct patient because blank or repeated patient cells do not carry the association.
Open the worksheet in WPS Office Spreadsheets and locate the Patient column and the diagnosis code columns. Confirm whether the patient identifiers are text or numbers, because this determines whether AutoFill uses Copy or Fill Series.
Fill the Patient Identifier Down and Sort by the Patient Column
Use this method when the worksheet has blank patient cells and you need to sort without breaking the patient-to-diagnosis relationship.
Blank cells in the Patient column prevent Excel or WPS Spreadsheets from recognizing that every diagnosis code row belongs to the same patient. Filling the identifier into each related row first gives every row a sortable patient value.
Click the first patient identifier cell, hold Shift, and click the last blank cell in the same patient block so all rows for that patient are selected.
Drag the fill handle from the bottom-right corner of the selection through the related diagnosis rows, release the mouse, click the AutoFill Options button, and choose Copy Cells so numeric identifiers do not create a series.
Move to the next patient identifier cell, drag the fill handle down through all rows for that patient, and choose Copy from the AutoFill options. Continue until every diagnosis code row has a patient identifier.
Select the entire data range including headers and diagnosis code rows, click the Data tab in WPS Office Spreadsheets, choose Sort, set Sort by to Patient, and confirm the order.

Convert the Range to a Table and Sort Through the Patient Filter
Use this method for a structured table layout with automatic filter arrows and repeatable sorting.
Keep Patient Diagnosis Codes Associated When Sorting in WPS Office Spreadsheets
In WPS Office Spreadsheets, fill blank patient identifiers down, convert the worksheet to a table, and sort by the Patient column so medical record rows stay matched with their diagnosis codes.
- 1. Open the workbook: Launch WPS Office, click Spreadsheets, and open the .xlsx or .xls file containing the patient diagnosis records.
- 2. Fill patient identifiers down: Select the first patient identifier cell, drag the fill handle through the related diagnosis rows, and choose Copy from the AutoFill options when using numeric IDs.
- 3. Convert the range to a table: Click the Insert tab, choose Table, confirm the range, and enable My table has headers to add filter arrows.
- 4. Sort by the Patient column: Click the Patient column filter arrow and choose Sort Ascending or Sort Descending; each diagnosis row stays with the correct patient.
- 5. Save the sorted file: Click the Menu button, choose Save As, and save the workbook in Excel .xlsx format for continued sharing and compatibility.

Frequently Asked Questions
Why do my diagnosis codes separate from the patient when I sort?
The Patient column has blank cells between repeated patient names, so only the first row carries the patient identifier. Fill the patient identifier down through every diagnosis code row before sorting.
How do I stop patient ID numbers from increasing when I fill down?
After dragging the fill handle, click the AutoFill Options button and choose Copy instead of Fill Series. This keeps numeric medical record numbers unchanged.
Can I sort the worksheet without creating a new Patient column?
Yes. Select the data range, convert it to a table from the Insert tab, and use the Patient filter arrow to sort. The diagnosis rows remain associated with the patient.
Will converting the data to a table change my workbook formatting?
WPS Spreadsheets applies a default table style, but the existing cell values and structure remain. You can change or clear the table style after sorting.
What should I do with blank separator rows before sorting?
Remove or exclude blank separator rows before sorting, or place them outside the table range, because blank rows can break filter ranges and separate associated patient records.




