How to Assign the First User ID to Duplicate Names in Excel
Question details
The user needs to standardize duplicate records by replacing multiple different IDs assigned to the same person with the very first ID originally generated for them.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Managing a database across multiple worksheets where users have been assigned multiple IDs over time, and entries need to be consolidated under their first assigned ID by matching first and last names.
- Observed behavior
- Duplicate names exist across records with different IDs instead of sharing a single, unified first User ID.
Ensure your first and last name columns do not contain trailing spaces, as this can prevent accurate matching. It is also highly recommended to format your data ranges as Tables before using advanced lookup functions.
Use Power Query to Merge Data and Extract the First ID
Power Query easily handles multi-column matching and allows sorting to pick the earliest date or first occurrence of an ID.
Power Query is the most robust tool for matching two datasets based on multiple criteria without complex formulas.
Convert both the original ID list and the duplicate entry list into Excel Tables by selecting the data and pressing Ctrl+T.
Go to the Data tab and select 'From Table/Range' for both tables to load them into the Power Query Editor.
In Power Query, select the duplicate entries table, go to the Home tab, and click 'Merge Queries'.
Select the original ID table from the dropdown, hold Ctrl, and click the First Name and Last Name columns in both tables to match them.
Expand the newly merged column to extract the 'User ID' and apply an Ascending sort on the date or ID creation column to ensure the first ID is prioritized.
Click 'Close & Load' in the Home tab to return the cleaned, unified data to a new Excel worksheet.

Use an Advanced Formula to Match Multiple Criteria
If you prefer formulas, use a multi-criteria array formula or an XLOOKUP to find the first occurrence of combined first and last names.
Easily Manage Duplicate Records with WPS Spreadsheet
WPS Spreadsheet offers powerful data handling features, including advanced lookup formulas like XLOOKUP and multi-column merging, to easily consolidate duplicate records and extract unique IDs.
- 1. Open Your Workbook: Launch WPS Spreadsheet and open the file containing your duplicate IDs.
- 2. Input the Lookup Formula: Select an empty cell in your target sheet and type the XLOOKUP or INDEX/MATCH multi-criteria formula.
- 3. Reference the Original IDs: Select the ranges in your source sheet that contain the correct original IDs and matching name columns.
- 4. Apply to All Rows: Press Enter and use the fill handle to drag the formula down for all duplicate names.

Frequently Asked Questions
Why is my lookup formula returning #N/A for identical names?
This usually happens due to hidden characters or trailing spaces in your text. Use the TRIM() function on your name columns to clean the data before attempting to match.
Can I use VLOOKUP to match both first and last names without modifying my source data?
Standard VLOOKUP only searches a single column. To use it for two criteria without modifying source data, you must rely on array formulas like INDEX and MATCH, or switch to the newer XLOOKUP function.
How does Power Query determine the 'first' ID?
Power Query reads data from top to bottom. If you sort your merged data by a date column (oldest to newest) before removing duplicates, it retains the top-most row, effectively keeping the very first ID assigned.




