Resources

Knowledge Base

Excel automation. Compare Rows From Different Tables

compare_rows0

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

Task

This sample compares a row from sheet1 with another row from sheet2.

Steps to automate

  1. Read Sheet1.
  2. Read Sheet2.
  3. Get the number of columns for each sheet.
  4. Check if both DataTables have the same number of columns.
  5. If their sizes are the same ask the user to enter the number of the first row and the second row.
  6. Compare the rows.
  7. Display if the rows have the same information or not.

Solution

  1. Read Sheet1 and Sheet2 using "Read Cell Range" activity.
  2. Using "Assign" activity saves in two variables the number of columns of each data table.
  3. Compare if the number of columns is equal using a "Flow Decision" activity.
  4. If the number of columns is not equal then display a message using "Message Box" activity.
  5. Otherwise, use a "Input Dialog" activity to allow the user to insert the rows that he/she wants to compare.
  6. Using a "While" activity to compare the rows.
  7. Display if the rows have the same information or not using a "Message Box" activity.

Compare_rows1Compare_rows2

Read more about Excel Automation here.