Delete Duplicate rows from excel

Dear Forum Members,

I am trying to delete the duplicate records from the excel. I have used “Delete Duplicate Rows” but it is not working and I also used DT.Defaultview.ToTable(True,“Columnname1”,“Columnname2”) and it is working if I take only 2 Columns where the values are same, but it will save only these 2 columns in the DataTable variable and if I take all variables in the above code, then it is not deleting the Duplicate rows. How can I achieve this. For more clearity, I have attached the screenshot.


Any help will be appreciated, Thanks in advance.

Hi @dimple.khurana

Check this

dt.AsEnumerable().GroupBy(Function(i) i.Field(Of String)("ColumnName")).Select(Function(g) g.First).CopyToDataTable()
((From LineNo In dt.DefaultView.ToTable(True,"Product").Select().ToList() Select (From row In dt.Select Where row("Product").ToString=LineNo("Product").ToString Select row).ToList(0)).ToList()).CopyToDatatable()
You can use multiple values

Hi Ashwin,

I tried the first option and it is working fine. Thanks for your help and quick response.
Really appreciate your time, Thanks

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.