Skip to main content

Copy Sheet

Copies a sheet from an excel file and creates a copy in the same file.

Common Properties

  • Name - The custom name of the node.
  • Color - The custom color of the node.
  • Delay Before (sec) - Waits in seconds before executing the node.
  • Delay After (sec) - Waits in seconds after executing node.
  • Continue On Error - Automation will continue regardless of any error. The default value is false.
info

If the ContinueOnError property is true, no error is caught when the project is executed, even if the Catch node is used.

Input

  • Excel File Descriptor - The ID of the excel file descriptor to copy the sheet from. This ID is generated by the Open Excel or the Create Excel node.
  • Sheet Name - The name of the sheet to be copied.
  • Copied Sheet Name - The name of the sheet to be created from the copied sheet.

Output

  • Excel File Descriptor - The ID of the excel file descriptor with the copied sheet. This ID is generated by the Open Excel or the Create Excel node.

Options

  • Switch To Sheet - Switches to the copied sheet upon completion of copying. If unchecked, the current sheet is retained.

How It Works

  1. Validates Input: Checks that file descriptor, source sheet name are provided
  2. Verifies Source Sheet: Confirms the sheet to be copied exists in the file
  3. Checks Target Name: If a copied sheet name is provided, verifies it doesn't already exist
  4. Generates Name: If no copied sheet name is provided, automatically generates one (e.g., "Sheet2", "Sheet3")
  5. Creates New Sheet: Creates a new sheet with the specified or generated name
  6. Copies Content: Duplicates all content, formatting, and formulas from the source sheet
  7. Switches Sheet (Optional): If the Switch To Sheet option is enabled, activates the newly copied sheet at cell A1

Requirements

  • The Excel file must be opened using Open Excel or created with Create Excel
  • The source sheet must exist in the file
  • The copied sheet name (if provided) must not already exist in the file
  • File must be saved after copying to persist the changes

Error Handling

Error CodeDescriptionSolution
Core.Excel.CopySheet.ErrOnCreateConfiguration parsing failedCheck node configuration is valid
Core.Excel.CopySheet.ErrOnMessageMessage parsing failedVerify input message format
Core.Excel.CopySheet.ErrFileDescriptorFile descriptor is emptyEnsure file is opened/created before copying
Core.Excel.CopySheet.ErrSheetSheet name is empty, doesn't exist, or target name already existsVerify source sheet exists and target name is unique
Core.Excel.CopySheet.ErrSwitchFailed to switch to copied sheetCheck that the copied sheet was created successfully

Usage Examples

Example 1: Create Template Backup

Make a backup copy of a template sheet:

- Open Excel (report_template.xlsx) -> fileDesc
- Copy Sheet:
- Excel File Descriptor: fileDesc
- Sheet Name: "Template"
- Copied Sheet Name: "Template_Backup"
- Switch To Sheet: false
- Save Excel (fileDesc)
- Close Excel (fileDesc)

Example 2: Create Monthly Reports

Duplicate a template for each month:

- Open Excel (annual_report.xlsx) -> fileDesc
- For each month in ["January", "February", "March", ...]:
- Copy Sheet:
- Excel File Descriptor: fileDesc
- Sheet Name: "Template"
- Copied Sheet Name: {{month}}
- Switch To Sheet: true
- Set Cell Value (A1, {{month}} + " Report")
- // Additional month-specific modifications
- Save Excel (fileDesc)
- Close Excel (fileDesc)

Example 3: Auto-Named Copy

Let the system automatically name the copied sheet:

- Open Excel (workbook.xlsx) -> fileDesc
- Copy Sheet:
- Excel File Descriptor: fileDesc
- Sheet Name: "Sales"
- Copied Sheet Name: "" (leave empty for auto-naming)
- Switch To Sheet: true
- // Result: Creates "Sheet2", "Sheet3", etc.
- Save Excel (fileDesc)

Usage Notes

  • If the copied sheet name is left empty, the system automatically generates a name like "Sheet2", "Sheet3", based on the total number of sheets
  • The copy operation duplicates all content, including data, formulas, formatting, and styles
  • The copied sheet name must be unique within the workbook
  • The original sheet remains unchanged
  • Charts and images are also copied to the new sheet
  • The Switch To Sheet option is useful when you want to immediately work on the copied sheet
  • Remember to save the file after copying to persist the changes

Tips

  • Use descriptive names for copied sheets to make your workbook more organized
  • When creating multiple copies in a loop, use dynamic naming with variables
  • Leave the copied sheet name empty if you just need a quick duplicate
  • Use the Switch To Sheet option when you plan to modify the copy immediately
  • Consider copying a template sheet at the start of your automation workflow
  • Always verify the source sheet exists before attempting to copy (use Get Sheets)
  • Save the file after copying to ensure the new sheet persists