Handling duplicates in datatable/excel

Hello, I need help on these 2 tasks below, and it has to do with handling duplicates in DT/excel.

What I need to do in my workflow is:

  1. Get a Reference No. (using a system in my company) for each Container listed (that is not a duplicate).

  2. Register ALL POs of the same container (duplicates) using the Reference No. assigned to the same container.

This is an exmple of my excel file:

PO No.|Container|Reference No.
123 |ABC| ???
456 |ABC|
234 |EFG| ???
567 |EFG|
891 |EFG|

The number of duplicates changes every time, so I need a dynamic solution.

NB. the columns headers are fixed and they cannot change (but I can add new If needed).

Thanks a lot

Giorgio

@giorgio.buono ,

Please follow below steps.

  1. Get distinct Containers
    image

  2. Iterate through all the unique containers and update respective reference number to all the occurrences. Using below Invoke method code.

dt.AsEnumerable.ToList.ForEach(Sub(row)
    If row("Container").ToString =strContNo Then
        row("RefNo")=srtRefNo
    End If
End Sub)

Arguments:

Change get reference number logic as per your need.
image

Output
image

Thanks,
Ashok :slight_smile:

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