How to remove duplicate rows in a table?

JenniferMurphy

Well-known Member
Joined
Jul 23, 2011
Messages
2,718
Office Version
  1. 365
Platform
  1. Windows
I have a fairly large table, PerfTbllog, with almost 2,000 rows and 20+ columns. The first column is entitled "Title". I want to remove all but 1 row with the same Title. I don't care which row is kept.

The table has both data and formulas and there is another table that references columns in the PerfTblLog table. The edited table must preserve the formulas.

I am able to delete the duplicate rows using Power Query, but I cannot figure out how to replace the original table with the edited version.

Is there a way to do that?
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
You can use a helper column "Count". Filter where it's not 1, select the rows, delete.
Book1
ABC
1TitleHdr2Count
2AppleCar1
3AppleCar2
4ApplePlane3
5ApplePlane4
6ApplePlane5
7OrangeBus1
8OrangeBus2
9OrangeRocket3
10OrangeRocket4
11OrangeBoat5
Sheet1
Cell Formulas
RangeFormula
C2:C11C2=COUNTIFS(PerfTblog[[#Headers],[Title]]:[@Title],[@Title])
 
Upvote 0
Hi Jennifer, does this work for you:

VBA Code:
Sub Remove_Duplicates()
    ActiveSheet.Range("PerfTbllog[#All]").RemoveDuplicates Columns:=1, Header:=xlYes
End Sub
 
Upvote 0
You can use a helper column "Count". Filter where it's not 1, select the rows, delete.
Book1
ABC
1TitleHdr2Count
2AppleCar1
3AppleCar2
4ApplePlane3
5ApplePlane4
6ApplePlane5
7OrangeBus1
8OrangeBus2
9OrangeRocket3
10OrangeRocket4
11OrangeBoat5
Sheet1
Cell Formulas
RangeFormula
C2:C11C2=COUNTIFS(PerfTblog[[#Headers],[Title]]:[@Title],[@Title])

Wow!!! Such a simple solution. I am embarrassed that I didn't think of that. Thank you very much.
 
Upvote 0
Hi Jennifer, does this work for you:

VBA Code:
Sub Remove_Duplicates()
    ActiveSheet.Range("PerfTbllog[#All]").RemoveDuplicates Columns:=1, Header:=xlYes
End Sub
This probably works, but the helper column solution was simpler. Thanks, anyway. Maybe someone else will see this solution and find it more useful.
 
Upvote 0
Even simpler would be to put your cursor anywhere in the table, then 'Remove Duplicates' (on the 'Data' ribbon tab), select only the 'Title' box, OK
 
Upvote 0
Solution
Even simpler would be to put your cursor anywhere in the table, then 'Remove Duplicates' (on the 'Data' ribbon tab), select only the 'Title' box, OK

OMG! Now I am really embarrassed. 😲🙃 I read in the paper about an Excel Nerds competition in Las Vegas. I guess I couldn't even pass the entry exam.

PS: Sorry, Cubist. But I have to go with this solution.
 
Upvote 0

Forum statistics

Threads
1,226,466
Messages
6,191,196
Members
453,646
Latest member
SteenP

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top