Compare two columns in excel

excel
activities

#1

How to compare two columns in excel… And printing out back only the matched values to the same excel sheet… ??


How to compare a row in excel with a column in another excel?
#3

Is it the same for excel files used in ui path also???


#4

You will probably want to use Read Range activity to create a datatable.
Assuming dt is your datatable variable then you can compare columns like,

Foreach row In dt
If row.Item(columnname1 as string or columnIndex1 as integer) = row.Item(columnname2 or columnIndex2)
Assign row.Item(column3) = row.Item(column1)

Then using Write Range (outside of the For Each), write entire datatable back on to the sheet with the added values.

So, basically with For Each activity, loop through each row in the table, If 2 columns are equal, Assign the item to a 3rd column. If the 3rd column doesn’t exist then use Add Data Column activity before the loop.

Thanks.

Also, if the table is large then you might do some looking into LINQ, mainly .Where and .Select which you can filter down the table to only the rows where columns are equal and loop through that array of rows.


#5

Thank you…


#6

Hello,

Can I have comparison of two columns automate through excel


By selecting the dates it should be run and stored in to excel.

Could You please help abt that.

Can you please send that class file