Duplicated Rows in Excel

I have a excel sheet 1 ,How to remove duplicated rows in excel to write in sheet 2,

by using linq query

Thank you

@ravisinghdas199

 uniqueRows = (From row In dtInput.AsEnumerable()
                  Select row).Distinct(DataRowComparer.Default).CopyToDataTable()

Hi @ravisinghdas199

Tr this:

(From d In dt.AsEnumerable
Group d By k1=d("column name").toString.trim()
Into grp = Group
Where grp.Count = 1
Select grp.First).CopyToDataTable

Regards

@ravisinghdas199

dt.AsEnumerable.GroupBy(Function(a) Tuple.Create(a("CName1").ToString,a("Cname2").ToString)).Select(Function(b) b.First).CopyToDataTable

Cheers

Hi @ravisinghdas199

Try this

dtUnique = dtInput.AsEnumerable().
    GroupBy(Function(row) row("ColumnName").ToString()).
    Select(Function(g) g.First()).CopyToDataTable()

Regards,

Hi @ravisinghdas199 ,

Use this Linq Query
(From d In dt.AsEnumerable
Group d By k1=d(“column name”).toString.trim()
Into grp = Group
Where grp.Count = 1
Select grp.First).CopyToDataTable

Regards
Sandy

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