activities
latest
false
UiPath logo, featuring letters U and I in white
Productivity Activities
Last updated Nov 21, 2024

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.
  3. 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.
  4. Select the Do container from inside the Excel Application Scope and create the following variables:

    Variable Name

    Variable Type

    Default Value

    rangeResult

    String

    N/A

    sheets

    List<String>

    N/A
  5. 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.
  6. 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.
  7. Select the Do container and create the following variables:

    Variable Name

    Variable Type

    Default Value

    rangeResult

    String

     

    sheets

    List<String>

     
  8. 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.
  9. Run the process. The automation process copies the data from one workbook to a new one and deletes the specified range of rows.

Was this page helpful?

Get The Help You Need
Learning RPA - Automation Courses
UiPath Community Forum
Uipath Logo White
Trust and Security
© 2005-2024 UiPath. All rights reserved.