<img src="//trc.taboola.com/1222697/log/3/unip?en=page_view" width="0" height="0" style="display:none">


The Knowledgebase articles are deprecated. Please visit the new Guides and Resources here: https://www.uipath.com/developers/guides-and-resources.

Knowledge Base

Compare Two Columns In Excel


  • To be able to run this example you need to install UiPath.Excel.Activities. See more details on how to install packages here.


This sample compares the first two columns of an Excel workbook and writes in the third column:
"=" if the numbers are equal.
"a" if the first number is greater.
"b" if the second number is greater.

Steps to automate

1. Read Excel file.
2. Compare column A with column B, row by row.
3. Write the appropriate value in column C.


  1. Get the information from the workbook into a data table using "Read Cell Range" activity.
  2. With the aid of a "For Each Row" activity you can process each row from the data table.
  3. Compare the value of column 0 (A in Excel) with column 1 (B in Excel).
  4. If these cells are equal, use a "Write Cell" activity to write in column C "=".
  5. Otherwise, you have to compare to find out which one is greater.
  6. When you write in column C, use a variable (rowNumber) to indicate the row that is processed.



 For an overiview of Excel Automation click here.