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.
- Get the information from the workbook into a data table using "Read Cell Range" activity.
- With the aid of a "For Each Row" activity you can process each row from the data table.
- Compare the value of column 0 (A in Excel) with column 1 (B in Excel).
- If these cells are equal, use a "Write Cell" activity to write in column C "=".
- Otherwise, you have to compare to find out which one is greater.
- 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.