Delete Duplicate Rows in Excel Using DataTable

Dear Experts,

I want to delete duplicate rows in Excel using Data Table. In this example, I want to delete rows where the item_no and amount are the same and I need only one record.

image

I want to delete rows highlight in yellow. If there is solution, please provide me. Thanks.
I also attached file for reference.
New.xlsx (9.0 KB)

Hi @Zaw_Win_Htun1

Try the below LINQ expression!

dt.AsEnumerable().GroupBy(Function(i) i.Field(Of String)(“Item _No”)).Select(Function(g) g.First).CopyToDataTable()

Regards

Hi @Zaw_Win_Htun1

Please have a look at this video.

Hope this will be helpful. Thank you.

Many Thanks.

Many Thanks. I’m still trying this .

1 Like

Hi @Zaw_Win_Htun1

Does it throws any error while executing?

Regards

Read into DT, delete Excel file, remove duplicate rows from DT, write DT to new Excel file.