Skip to main content

Robot Task Activities - Excel Sheet​

The Excel Sheet activities create, select, rename, protect, move and copy worksheets in the active workbook.

The Excel Sheet category in the activity list, from Activate Sheet to Set page orientation

All activities in this category must be inside a New Excel or Attach to Excel container activity. See Excel. Sheet names are matched exactly, and an activity fails if the sheet it names is not found. Variables are resolved in every field.

warning

With DisplayAlerts cleared on the parent container, which is the default, Excel deletes and overwrites without asking. Save the workbook before you change its structure.

Selecting a sheet: click the Click to select Excel element link, then select the sheet, hold CTRL and click any cell in the sheet. The sheet name is filled in automatically. Excel must already be running.

The prompt shown in Excel while picking a sheet, asking to select the sheet and press CTRL while clicking


Activate Sheet​

Makes the sheet the active sheet.

The Activate Sheet activity, with the Click to select Excel element link and the Sheet field

  • Sheet: the name of the worksheet

Select all Sheets​

Selects all sheets in the active workbook.


Select Sheet​

Selects the sheet. Same field as Activate Sheet.


Create Sheet​

Creates a sheet with the name in Sheet, after the active sheet. Fails if a sheet with that name already exists.


Delete Sheet​

Deletes the sheet. Same field as Activate Sheet.


Hide Sheet​

Hides the sheet. Same field as Activate Sheet.


Show Sheet​

Shows a hidden sheet. Same field as Activate Sheet.


Copy Sheet​

Copies the sheet.

The Copy Sheet activity, with the Source and Destination fields

  • Source: the name of the worksheet to copy
  • Destination: the name of the new worksheet, which is placed right after the source; fails if a sheet with that name already exists

If Destination is empty, Excel copies the sheet into a new workbook instead.


Move Sheet​

Moves the sheet to a new position.

The Move Sheet activity, with the Sheet and After sheet fields

  • Sheet: the name of the worksheet to move
  • After sheet: the name of the worksheet after which it is placed

If After sheet is empty, Excel moves the sheet into a new workbook instead.


Rename Sheet​

Renames the sheet.

The Rename Sheet activity, with the Sheet and New name fields

  • Sheet: the name of the worksheet to rename
  • New name: the new name; fails if it is empty or a sheet with that name already exists

Protect Sheet​

Protects the sheet against changes, optionally with a password.

The Protect Sheet activity, with the Sheet and Password fields

  • Sheet: the name of the worksheet to protect
  • Password: the password needed to remove the protection; leave it empty to protect without a password

Unprotect Sheet​

Removes the protection from the sheet.

  • Sheet: the name of the worksheet to unprotect
  • Password: the password the sheet was protected with

Set page orientation​

Sets the print page orientation of the sheet.

The Set page orientation activity, with the Sheet and Orientation fields

  • Sheet: the name of the worksheet
  • Orientation: "Portrait" or "Landscape"

Tips​

  • Add an Activate Sheet activity before a group of Excel Cell, Excel Row or Excel Column activities. Those activities act on the active sheet, so being explicit avoids writing to whichever sheet happened to be active
  • Use a Variable in the New name of a Rename Sheet activity to stamp sheets with a date or a record identifier
  • Unprotect Sheet must run before any activity that writes to a protected sheet, otherwise the write fails
  • Use Copy Sheet to duplicate a formatted template sheet rather than rebuilding headers and formatting with individual Set Cell value activities