UiPath Activities

The UiPath Activities Guide

Manipulate Range Selections

Using this example you can copy an entire sheet from one workbook, copy it into a new workbook and alter its content by deleting a range of rows.
The example below explains how to work with activities like Copy Sheet and Delete Range. You can find these activities in the UiPath.Excel.Activities package.

This is how the automation process can be built:

  1. Open Studio and create a new Process named by default Main.
  2. Drag a Sequence container in the Workflow Designer.

Note:

Make sure to have the .xlsx file inside the project folder. You can use your own .xlsx file or download the example we have provided at the bottom of this page. The .xlsx file is used for retrieving and processing data to generate a new database.

  1. Add an Excel Application Scope inside the sequence container.
    • In the Properties panel, add the path of the .xlsx file, in this case example.xls, in the WorkbookPath field.
    • Select the check boxes for the AutoSave, CreateNewFile and Visible options. The robot is now allowed to create a new Excel workbook, to automatically save all the changes made to it and to open the Excel file in the foreground while performing actions on it.
  2. Select the Do container from inside the Excel Application Scope and create the following variables:
Variable Name
Variable Type
Default Value

rangeResult

String

-

sheets

List<String>

-

  1. Add an Excel Copy Sheet activity inside the Do container.
    • In the Properties panel, add the expression "copy_destination.xlsx" in the DestinationFilePath field.
    • Add the name "New Sheet" in the DestinationSheetName field and the value "SalesOrders" in the SheetName field.
  2. Place another Excel Application Scope below the first one.
    • Add the path "copy_destination.xlsx" in the WorkbookPath field.
    • In the Properties panel, select the check boxes for the AutoSave, CreateNewFile and Visible options. The robot is now allowed to create a new Excel workbook, to automatically save all the changes made to it and to open the Excel file in the foreground while performing actions on it.
  3. Select the Do container and create the following variables:
Variable Name
Variable Type
Default Value

rangeResult

String

-

sheets

List<String>

-

  1. Add an Excel Delete Range activity inside the Do container.
    • In the Properties panel, add the expression "A10:G20" in the Range field and the name "New Sheet" in the SheetName field.
    • Select the check box for the ShiftCells option. By checking this option, the cells are shifted according to the Shift Option.
    • Select the option ShiftUp from the ShiftOption drop-down list.
  2. Run the process. The automation process copies the data from one workbook to a new one and deletes the specified range of rows.
     
     
    Download example

Updated about a month ago


Manipulate Range Selections


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.