Identify duplicate rows and update cell value for the it as duplicate

Hi I need help in to identify duplicate in excel and then updating *the duplicate rows with cell value as “duplicate “ on basis of columnA
For example - input is
ColumnA columB status
Abc 123
Abc 234

Output -
ColumnA columnB status
Abc 123 “”
Abc 234duplicate

1 Like

Hey @amangupta4644

  1. Use ForEachRow to iterate through the data table & store the output index in a variable as well in int_RowIndex

  2. Make an IF condition to check if the item is duplicate using the following query

dt.Rows.Take(int_RowIndex).Count(Function(row) row("ColumnA").ToString.Equals(CurrentRow("ColumnA").ToString)) > 0
  1. If the above condition is true we need to consider it as duplicate
//Assign Activity
CurrentRow("Status") = "Duplicate"

Hope this helps

Thanks
#nK

Actually I have to only update those rows as duplicate if my columnB is blank or null. How can I append this additional condition ?
So first I have to check for duplicate rows and only if columnB is not null then do the update of duplicate value

1 Like

Hey @amangupta4644

dt.Rows.Take(int_RowIndex).Count(Function(row) row("ColumnA").ToString.Equals(CurrentRow("ColumnA").ToString)) > 0 AndAlso string.isNullOrEmpty(Convert.ToString(CurrentRow("ColumnB")))

Thanks
#nK