How remove duplicate name or data in row

How to remove duplicate name or other data in excel row

Try remove duplicate rows.

1 Like

please send any example

Duplicate rows.xaml (6.4 KB)

its not working for excel file. please help for excel file

Duplicate rows.xaml (8.5 KB) sample.xlsx (8.4 KB)

Its not working please tell other ways please help

It works only when all the columns has same values.
Try using Linq .

is following your requirement:

  • check if values from Column1 occurs more then 1 time
  • if souch rows exist, then remove all of these rows

result would be: only row b|2

If you want to remove duplicates where all the columns are same, use remove duplicate row activity.
If you want to compare specific column and remove duplicates, use

newDatatable = oldDatatable.DefaultView.ToTable(true, “Column1”);

If you want to remove duplicate rows based on multiple columns, specify the column names separated by ‘,’

newDatatable = oldDatatable.DefaultView.ToTable(true, “Column1”, “Column2”);

If you don’t want to keep the original row along with duplicate rows, then use Linq quey. (see below steps)

  1. Lets consider your table as, dtTable
  2. First try getting all the duplicate rows,

dtDuplicateTable = dtTable.AsEnumerable().GroupBy(Function(dr) dr.Field(Of String)(“Column1”)).Where(Function(g) g.Count() > 1).SelectMany(Function(g) g).ToList().CopyToDataTable

  1. Now compare the original table with duplicate table and exclude the duplicate rows from original table,

dtFinalTable = dtTable.AsEnumerable().Except(dtDuplicateTable.AsEnumerable, DataRowComparer.Default).CopyToDataTable

P.S: Check for record existence before converting as CopyToDataTable while doing complete implementation. Otherwise, if there are no records found, the statement will through exception.

Hope this helps!

what i need is delete enter row please tell other method

I have column B only have multiple name ok.
I need Delete enter row.
i need only one name no need to repeated ,please help

we have seen your input by your sample.xls. Now please share the expected output as excel or text with us.

I have column B only have multiple name ok.
I need Delete enter row.
i need only one name no need to repeated

not clear

Example.xlsx (10.5 KB)

In this file have item column name in column have “eraser” item name is there i need only one time in row other row can delete or remove .
i need one time item name “eraser”

use newDatatable = oldDatatable.DefaultView.ToTable(true, “Column1”);
instead of Column1, specify your column name.