logo
search
Function Problems

How to Sort Excel Data to Match the Order on Another Sheet

Maira MehtabMaira Mehtab Sep 20, 2026 868 views

Question details

The user needs to reorder or merge columns of data on one worksheet to match the exact sequence of corresponding data on another worksheet without manual copying.

Product
Spreadsheet
Device & OS
not provided
Scenario
Aligning and merging two datasets from different sheets (e.g., names with numbers and names with colors) by using a matching key.
Observed behavior
The user is trying to find an efficient formula or automated sorting procedure to merge columns instead of copying and pasting rows manually one by one.
Before you start

Before proceeding, ensure both worksheets contain a common unique identifier (like a Name, ID number, or Email) to act as the matching key for sorting and aligning.

Solution 1Recommended

Use VLOOKUP to Pull and Align Data from the Second Sheet

Instead of physically sorting the second sheet, use a lookup formula on the master sheet to automatically pull data in the exact matched order.

This is the most efficient method for merging data across sheets. By using a matching key, Excel will find the corresponding row on the second sheet and display it perfectly aligned on the first sheet.

1
Select an empty column on the master sheet

Click on the first empty cell next to your master list on Sheet 1 (e.g., cell C2).

2
Enter the VLOOKUP formula

Type =VLOOKUP(A2, Sheet2!A:B, 2, FALSE), assuming A2 is your matching key (like a Name), and Sheet2!A:B is the range on the second sheet containing the data you want to retrieve.

3
Apply the formula to all rows

Press Enter to see the result. Then, double-click the small square fill handle at the bottom-right corner of the cell to drag the formula down to the rest of the rows.

Keep Static Values: To prevent the data from breaking if the second sheet is deleted, copy the new column, right-click, and select 'Paste as Values' to remove the formulas.
Free Spreadsheet Software

Seamlessly Sort and Match Data with WPS Spreadsheet

WPS Spreadsheet offers powerful built-in functions like VLOOKUP, XLOOKUP, and Advanced Custom Sorting to help you organize data across multiple sheets instantly. It eliminates the need for manual row copying and is completely free.

  1. 1. Open your workbook in WPS Spreadsheet: Launch WPS Office, open your Spreadsheet file, and navigate to the master sheet where you want to align the data.
  2. 2. Insert the lookup formula: Type =VLOOKUP( and follow the intuitive on-screen formula prompt to select your matching key and the data range on the second sheet.
  3. 3. Auto-fill to match all records: Drag the formula down using the fill handle to automatically match and pull all corresponding records in the correct order.
Fully compatible with Microsoft Excel formats (.xlsx, .xls, .csv).Supports advanced lookup functions to merge and align datasets effortlessly.Intuitive Custom Sort feature to easily organize complex data.Free, lightweight, and user-friendly alternative to Microsoft Excel.
QA img-9

Frequently Asked Questions

Why is my VLOOKUP formula returning an #N/A error when matching data?

The #N/A error means the application cannot find a match for your lookup value. Ensure that both sheets have identical matching keys without extra spaces (you can use the TRIM function to clean data) and that the lookup value exists in the very first column of your selected table array.

Can I match the order using XLOOKUP instead of VLOOKUP?

Yes, XLOOKUP is an excellent modern alternative. You can use =XLOOKUP(A2, Sheet2!A:A, Sheet2!B:B) to search for the matching value in column A of Sheet 2 and return the corresponding value from column B, without worrying about which column comes first.

What if I have duplicate names when trying to match data across sheets?

Standard lookup functions will only return the first match they encounter. If your dataset has duplicates, you need a more unique identifier. You can create a unique key by combining columns, such as concatenating First Name and Last Name using =A2&B2, and using that new column to match.

Is it possible to sort data by a custom list rather than using a formula?

Yes. If you have a specific list of names or categories in a required order, you can go to the Data tab, select Sort, and under the 'Order' dropdown, choose 'Custom List'. From there, you can manually input or import the exact sequence you want your data to follow.