Read and Review Automation Anywhere Documentation

Automation 360

Close Contents

Contents

Open Contents

Example of using a conditional statement

  • Updated: 11/17/2020
    • Automation 360 v.x
    • Build
    • RPA Workspace
    • Examples

Example of using a conditional statement

In this example, you build a bot that prints a message based on whether a cell has a value or is empty. Use the actions from the Excel basic or Excel advanced, If, and Message Box packages.

Prerequisites

Before building this bot, save an empty Excel worksheet to the desktop.

Because this bot does not create a new Excel worksheet, you can use either the Excel basic or Excel advanced packages.

Note: All of the actions must be from the same package.

Procedure

  1. Open a new bot.
    1. On the left panel, click Automation.
      A list of available bots and forms is displayed.
    2. Click Create new > Bot.
    3. Enter a bot name and click Create and edit.
  2. Use the Open action from the Excel basic or the Excel advanced package to open the Excel sheet.
    1. Double-click or drag the Open action.
    2. Enter a session name.
    3. Click Browse to provide the file path to the empty Excel worksheet on the desktop.
  3. Use the Get single cell action to assign the value of a cell to a string variable.
    1. Double-click or drag the Get single cell action from the same package that you used for the Open action.
    2. Provide the session name that you used in the Open action.
    3. Select the Active cell option.
    4. In the Store cell contents to field, create the variable Output.
  4. Use the If action to configure the conditional statement.
    1. Double-click or drag the If action.
    2. Select String from the Condition drop-down list.
    3. In the Source value field, insert the variable Output.
    4. Select Equals to as the Operator.
    5. Leave the Target value field empty.
  5. Insert a Message box into the If container.
    1. Drag the Message box action.
    2. In the Enter the message to display field, enter Cell is empty.
  6. Use the Else and Message box actions to configure the alternative sequence of actions.
    1. Drag the Else action next to the If action.
    2. Drag the Message box action into the Else container.
    3. In the Enter the message to display field, enter Cell is not empty.
  7. Click Save.
  8. Run the bot.
    As the bot runs, the message box appears with the message Cell is empty.
  9. Enter a value into the cell located at A1 in the Excel sheet and save the sheet.
  10. Run the bot.
    As the bot runs, the message box appears with the message Cell is not empty.
Send Feedback