How to read duplicate cells in excel

I want to know if there is any duplicates in the excel file and if I found out then I need to use if can I do this using uipath

Hi @Funky_Monks
U mean there is only one column having duplicate or more than one column or row

More than one column

I need to check invoice column and if I found any duplicates then I need to apply if condition and need to do some changes in the page

Hi @Funky_Monks

If possible can you provide the sample file/data for more and better understanding.

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

Hi @Funky_Monks
If u need to checkn for each and very column try this appraoch

  1. Read the excel and store in dt1

  2. Now use For Each activity with values as dt1.Column (Type Argument System.Data.DataColumn)

inside the loop do the following thing

use an if condition with condition as

dt1.AsEnumerable().Select(Function(r) r(item.ColumnName.ToString)).ToList.Distinct.Count<dt1.AsEnumerable().Select(Function(r) r(item.ColumnName.ToString)).ToList.Count

If the condition is True , Then it indicates that column had duplicates

else it does not have any duplicates

Hope you understand the logic for this

Mark it as solution if it works for u

Nived N

Tq I willl check it and let you know

1 Like

Tq for replying but I don’t have the file with me and I was not allowed to share the file without permission

@NIVED_NAMBIAR @Pratik_Wavhal how can I use count for counting duplicate values in an excel or how can I count duplicate values in an excel

U mean for column ?

Yes @NIVED_NAMBIAR , I have duplicate invoice values in a column and I need to count that number and if it is >2 then I need to use a if condition saying that invoice count variable >1then one process else another process need to develop

Hi @Funky_Monks

Are u comparing the invoice column only here ?

@yes I have only duplicate values in invoice column and have to count those values only

U can Try this

Read the excel and store in dt1

Then use a for each row to loop through the datatable — dt1.DefaultView.ToTable(True,“invoice”) [ for each item in dt1.DefaultView.ToTable(True,“invoice”)]

Do the following in the things in loop

use an if condition with condition as

dt1.AsEnumerable().Where(Function(r) r(“invoice”).ToString.Equals(item.ToString)).Count>2

if the condition is True
It implies that for that invoice value there are more than 2 values of same


Nived N

I guess this will do @NIVED_NAMBIAR , I am thankful for your help really it means a lot

1 Like

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