Data Import & Export

How to Combine Two Student Rows into One Excel Row

Tauseeq MagsiTauseeq Magsi Nov 11, 2026 868 views

Question details

The user needs a method to consolidate data where each student has two separate rows, moving the data from the second row into additional columns of the first row to create a single, comprehensive record per student.

How to Combine Two Student Rows into One Excel Row
Product
Excel
Device & OS
not provided
Scenario
Reorganizing poorly structured student records where information is split across two rows instead of a single consolidated row.
Observed behavior
Currently, student data is fragmented into multiple rows, making it difficult to analyze. The goal is to append the second row's data into new columns on the first row's level.
Before you start

Ensure your data is sorted by student name or ID so that the two rows for each student appear consecutively, and create a backup of your worksheet to prevent accidental data loss during formula application.

Solution 1Recommended

Use XLOOKUP and COUNTIF to Retrieve the Second Row

This method uses XLOOKUP's bottom-up search feature combined with COUNTIF to fetch the second occurrence of a student's record and place it alongside the first.

This approach is highly effective if every student appears exactly twice in your dataset. By setting XLOOKUP's search mode to -1, you instruct Excel to search from the bottom of the array up, effectively grabbing the second row's data.

1
Identify the target columns

Create new column headers next to your first set of data (e.g., starting in column M) to hold the values you want to retrieve from the second row.

2
Enter the XLOOKUP formula

In the first cell of your new columns (e.g., M2), type the formula: =IF(COUNTIF($A$2:$A2,$A2)=1,XLOOKUP($A2,$A$2:$A$11,G$2:G$11,,0,-1),""). Adjust the column references so column A points to the student ID and column G points to the data you want to retrieve.

3
Apply the formula

Press Enter to execute the formula. Then, click the small square at the bottom-right corner of the cell (fill handle) and drag it across the columns and down the rows to populate the data for all students.

Use XLOOKUP and COUNTIF to Retrieve the Second Row
Formula Output: The formula will output the second row's data on the first row of each student and leave the second row blank, making it easy to filter and delete the duplicates later.
Advanced Data Processing

Combine Multiple Rows Efficiently with WPS Spreadsheet

WPS Spreadsheet offers comprehensive support for advanced lookup functions like XLOOKUP, allowing you to easily consolidate duplicated records, merge rows, and manage complex datasets with zero hassle.

  1. 1. Open your document: Launch WPS Spreadsheet and open the workbook containing your fragmented student data.
  2. 2. Apply the XLOOKUP formula: In an empty column adjacent to your data, enter the recommended XLOOKUP and COUNTIF combination formula.
  3. 3. Drag to fill: Use the smart fill handle to apply the formula down the column, instantly merging the student records side-by-side.
  4. 4. Filter and clean: Navigate to the 'Data' tab and use the 'Filter' tool to hide or remove the now-redundant secondary rows.
Fully compatible with Microsoft Excel formulas, including XLOOKUP and complex nested arrays.Intuitive user interface for faster data manipulation, filtering, and consolidation.Built-in data cleaning tools to effortlessly remove duplicates and organize student records.Lightweight software that processes large datasets quickly without lagging or crashing.
microsoft office alternative - wps office

Frequently Asked Questions

Can I combine rows without using complex formulas?

Yes, if you prefer not to use formulas, you can use the Power Query feature. Load your table into Power Query, group the data by the student ID or name, and then pivot the data to flatten the rows into a single record.

Why is my XLOOKUP formula returning an error?

Ensure that your data ranges are locked using absolute references (like $A$2:$A$11). If the ranges are not locked, they will shift when you drag the formula down or across, resulting in #N/A or #VALUE! errors.

How do I remove the empty or duplicate rows after consolidating?

Once you have successfully merged the data into new columns, copy the entire new data range and paste it back over itself as 'Values' (Right-click > Paste Special > Values) to remove the formulas. You can then sort the data or use the 'Remove Duplicates' feature under the Data tab to safely delete the older, fragmented rows.

What if a student has three rows instead of two?

The standard XLOOKUP formula with a -1 search mode is designed to find only the last (second) entry. If a student has three or more rows, you will need to use a FILTER function wrapped in TRANSPOSE to spill all matching records horizontally across columns.