Compare two columns in Excel

Task Description

Automation Anywhere provides easy Excel Automation. For more information see Excel Automation Solution. This examples shows how to compare two columns in an Excel sheet.

T22.atmx     Compare-Values.xls

Note: Save the xls in C: drive, the .atmx file in My Documents -> Automation Anywhere -> Automation Anywhere -> My Tasks

Solutions

Open an Excel sheet

  • From Application Category->Excel, Select 'Open Spreadsheet' option

Create Variable

  • Click on Tools -> Variable Manager. Create variable Cell1 and Cell2 of type "value".

Insert Loop command

  • Insert loop command for option Times. Specify the number of rows to compare

Compare Cells

  • All of the following commands need to be entered within the Loop
  • Excel : Get value of Active cell and assign to variable "Cell1"
    Excel : Go to one cell right of active cell
    Excel : Get value of Active cell and assign to variable "Cell2"
    Excel : Go to one cell right of active cell
  • Compare Cell1 and Cell2 variables and based on the comparison results perform the required task.
  • Go to next row in the Excel document.

T22-1

Screenshot 1

T22-2

Screenshot 2

T22-3

Screenshot 3

When you run this task, it compares two Excel columns.