Remove Duplicate Rows Except for 1st Occurrence in Excel (7 Ways)

Method 1 – Remove Duplicate Rows Except 1st Occurrence Using Remove Duplicates Feature

  • Select the entire datasheet. In the sample dataset, it is B4:D15.
  • Go to the Data tab >> from Data Tools >> select Remove Duplicates.

Remove Duplicate Rows Except for 1st Occurrence in Excel

The Remove Duplicates dialog box will open. By default, all the columns are checked and My data has headers box is ticked.

  • Click OK.

It will remove the duplicate rows.

Remove Duplicate Rows Except for 1st Occurrence in Excel

This will be your output.

Read More:  How to Remove Duplicate Names in Excel 


Method 2 – Remove Duplicate Rows Except 1st Occurrence Using Advanced Filter

  • Select the range. In our case it is B4:D15.
  • Go to the Data tab >> select Advanced Filter.

Remove Duplicate Rows Except for 1st Occurrence in Excel

The Advanced Filter window will open.

  • Enter your range in the List range box and tick the Unique records only box.
  • Click OK.

Remove Duplicate Rows Except for 1st Occurrence in Excel

The output will be like this.

Remove Duplicate Rows using Advanced Filter

Read More: How to Remove Duplicates but Keep the First Value in Excel 


Method 3 – Remove Duplicate Rows Except 1st Occurrence using UNIQUE Function

  • Select a cell. In our case it is F4.
  • Enter the following formula,
=UNIQUE(B4:D15)
  • Press ENTER to remove the duplicate values.

After some formatting, this is the output in our worksheet.

Remove Duplicate Rows using UNIQUE function

Note: The UNIQUE function is available only in the latest versions like Excel 365 and Excel 2021. This method may not work if you are using an older version of Excel.

Read More: Excel Formula to Automatically Remove Duplicates 


Method 4 – Remove Duplicate Rows Except 1st Occurrence Using Power Query

  • Select the entire data range that you are going to use. In our case it is B4:D15.
  • Go to Data tab >> select From Table / Range.

emove Duplicate Rows Except 1st Occurrence Using Power Query

A Create Table window will open.

  • Click OK.

The Power Query window will pop up.

Remove Duplicate Rows Except for 1st Occurrence in Excel

  • Select the entire table, Right-click on it and select Remove Duplicates.

Remove Duplicate Rows Except for 1st Occurrence in Excel

All the duplicate values will be removed.

  • Transfer this table to your original workbook by clicking Close & Load.

Remove Duplicate Rows using Power Query

A new sheet will be created in the workbook. Name the table. In our case, it is named as Table5.

Remove Duplicate Rows Except for 1st Occurrence in Excel

Read More: How to Delete Duplicates But Keep One Value in Excel 


Method 5 – Remove Duplicate Rows Except 1st Occurrence Using COUNTIF Function

To apply this method, you have to make two new columns in your datasheet. The columns are labeled as Merged and Count.

  • Enter the formula in cell E5.
=B5&” “&C5&” “&D5

We have used this formula to merge the values of cells B5, C5, and D5. “ ” is used to put a space among these cell values.

  • Press ENTER and 1001 Jack Finance will appear in cell E5.

Remove Duplicate Rows Except for 1st Occurrence in Excel

  • Use the Fill Handle to AutoFill the formula to the remaining cells.

  • In the F5 cell, enter the following formula,
=COUNTIF($E$5:$E$15,E5)

This formula will tell you how many times a particular cell value appears. For example, when you press ENTER, cell F5 will show 3 in return. This is because the cell value in E5 ( that is, 1001 Jack Finance) is in the range E5:E11 three times (check E5, E9, E11).

Remove Duplicate Rows Except for 1st Occurrence in Excel

  • Use the Fill handle to AutoFill up to cell F15.

Remove Duplicate Rows using COUNTIF function

  • Select the whole dataset, go to Data tab >> select Sort and Filter >> and select Filter.

Remove Duplicate Rows Except for 1st Occurrence in Excel

A drop-down menu will appear in each column header.

Remove Duplicate Rows Except for 1st Occurrence in Excel

  • In the Count column, click the drop-down menu and tick the box for 3.

Remove Duplicate Rows Except for 1st Occurrence in Excel

All the rows having 3 in the Count column will show up.

  • Select all the rows except for the first one, and delete them manually.

Remove Duplicate Rows Except for 1st Occurrence in Excel

You have to repeat this task for all the boxes until you have only the box containing 1 after clicking the drop down list.

Remove Duplicate Rows Except for 1st Occurrence in Excel

Your result will be as shown below.

All the duplicate rows have been removed.


Method 6 – Remove Duplicate Rows Except 1st Occurrence Using Conditional Formatting

  • Create a new column. We have named it Merged.
  • Go to Home tab >> select Conditional Formatting >> select New Rule.

Remove Duplicate Rows Except for 1st Occurrence in Excel using Conditional Formatting

A New Formatting Rule window will open.

  • Select a Rule Type. In our case, it will be Use a formula to determine which cells to format.
  • Enter the following formula in the box.
=COUNTIF($E$5:$E5,$E5)>1

Format as required.

This formula will format the cells that are duplicated in your dataset.

Remove Duplicate Rows Except for 1st Occurrence in Excel

  • Click OK.

  • Put Filter on for the Merged column.

  • Choose Filter by Color and select the red colored box.

Remove Duplicate Rows Except for 1st Occurrence in Excel

All the red colored cells will open.

  • Delete the rows using COUNTIF Function.

Remove Duplicate Rows Except for 1st Occurrence in Excel by Conditional Formatting


Method 7 – Remove Duplicate Rows Except 1st Occurrence Using VBA

  • Go to the Developer tab >> select  Visual Basic.

Remove Duplicate Rows Except for 1st Occurrence in Excel using VBA

  • Go to Insert tab>>Module.

A Module window will appear.

  • Enter the following code.
Sub RemoveDuplicates ()
Dim Rng As Range
Set Rng = Range("B4:D15")
Rng.RemoveDuplicates Columns:=Array(1, 3), Header:=xlYes
End Sub

Remove Duplicate Rows using VBA

This code will create a macro that will remove duplicate rows from the cell range B4:D15. To do so, we’ve created a Sub Procedure RemoveDuplicates, declared Rng as Range, used the Set method to set the range, and also used the VBA RemoveDuplicates method where in the Array given column numbers 1 & 3 to compare two columns’ values so that it only removes duplicates rows.

  • Click the Run button.

Remove Duplicate Rows Except for 1st Occurrence in Excel

All the duplicate rows will be removed.


Download Practice Workbook


Related Articles


<< Go Back to Remove Duplicates in Excel | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Akib Bin Rashid
Akib Bin Rashid

AKIB BIN RASHID, a materials and metallurgical engineer, is passionate about delving into Excel and VBA programming. To him, programming is a valuable time-saving tool for managing data, files, and internet-related tasks. Proficient in MS Office, AutoCAD, Excel, and VBA, he goes beyond the fundamentals. Holding a B.Sc in Materials and Metallurgical Engineering from Bangladesh University of Engineering and Technology, MD AKIB has transitioned into a content development role. Specializing in creating technical content centred around Excel and... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo