How do I get the index of the cell which holds the same value in the previous rows?

Hey all,

I look for duplicate values in an Excel column “PV Number” and add remarks as “Duplicate of row”.

image

I’m using the below attached code for this condition.

dt.AsEnumerable.GroupBy(Function(r) r(“PV Number”).ToString).Where(Function(g) g.Count>1).SelectMany(Function(g) g).ToList.ForEach(
Sub(r)
If (String.IsNullOrEmpty(r(“REMARKS”).ToString)) Then
r(“REMARKS”)=“DUPLICATE OF ROW”
End If
End Sub
)

How do I get the index like in the below attached screenshot.

Hi,
one possibility would be to add an extra column to your datatable.
Then you can use a loop to fill that new field with an incremented number (in your example 1-7) and use that field as index for the Remarks text.