How to compare two excel columns in same excel sheet and count duplicate values

I want to compare two columns namely column A and column B. Column A contains names that are dealing different people in column B. I am attaching a sample excel file. I want outcome like this

Column A Column B
Albert 5
John 5

sample.xlsx (8.2 KB)

Hi,

How about the following expression?

dtResult = dt.AsEnumerable.GroupBy(Function(r) r("Column A").ToString).Select(Function(g) dt.Clone.LoadDataRow({g.key,g.Count},False)).CopyToDataTable()

Regards,

1 Like

I have implemented it by using Dictionary. But I want to solve it more easily by using if and for conditions.

Hi @enthusiastic

Please try the below workflow hope it helps, as you told you want using if and for conditions I have used them, try and let me know if you have queries
CountValuesInAColumn.xaml (11.6 KB)

Hope this helps.

1 Like