Delete Worksheets from Excel in Power Automate
PDF4me Delete Worksheets is a Power Automate action that removes one or more sheets from an Excel workbook by name, by index, or both, in a single call. Use it to strip sample sheets from templates, drop temporary calculation tabs before distributing a report, or clean up old worksheet tabs on a schedule, all without opening Excel.
What this action does
PDF4me Delete Worksheets takes an Excel file plus a list of worksheet names, worksheet indexes, or both, and returns the workbook with the matching sheets removed. A built-in safety check blocks the request if it would delete every worksheet, since a valid workbook must always keep at least one.
Authenticating Your API Request
To access the PDF4me Web API through Power Automate, every request must include a valid API key. Authentication validates your identity and enables the connector to reach PDF4me's Excel worksheet deletion service from your flow.
Important Facts You Should Not Miss

Map File Content and File Name from a prior action, then set Worksheet Names and/or Worksheet Indexes to choose which sheets to delete.
Parameters
Required: File Content and File Name must always be provided. At least one of Worksheet Names or Worksheet Indexes must identify a sheet to delete, and at least one worksheet must remain after deletion.
| Parameter | Required | What it does | Example |
|---|---|---|---|
| File Content | Required | Base64 or buffer content of the source Excel file, typically mapped from a prior action like SharePoint or OneDrive Get File Content. | [File Content from Get File] |
| File Name | Required | Name of the Excel file including its extension, used for processing and output naming. | data.xlsx |
| Worksheet Names | Conditional | Comma-separated list of worksheet names to delete. Case-sensitive, and combines with Worksheet Indexes as a union when both are set. Required only if Worksheet Indexes is left blank. | Temp,Draft,Old |
| Worksheet Indexes | Conditional | Comma-separated list of 1-based worksheet indexes to delete, for example "1,3" for the first and third sheets. Required only if Worksheet Names is left blank. | 1,3 |
What Does Delete Worksheets Return?
| Field | Type | What it contains |
|---|---|---|
document | Base64 | Excel document with the specified worksheets deleted. |
Success | Boolean | true when the deletion completed, false if the request failed validation or processing. |
Error Message | String | Description of what went wrong, null when Success is true. |
Errors | Array | Detailed error entries, empty when Success is true. |
- JSON Response
- Delete-All Error
- Invalid Worksheet Error
{
"document": "[Base64 Excel Content with Worksheets Deleted]",
"Success": true,
"ErrorMessage": null,
"Errors": []
}
{
"document": null,
"Success": false,
"ErrorMessage": "Cannot delete all worksheets. At least one worksheet must remain. Total worksheets: 3, Attempting to delete: 3",
"Errors": [
{
"Code": "WORKSHEET_DELETION_ERROR",
"Message": "Cannot delete all worksheets. At least one worksheet must remain."
}
]
}
{
"document": null,
"Success": false,
"ErrorMessage": "Invalid worksheet selection",
"Errors": [
{
"Code": "WORKSHEET_ERROR",
"Message": "Worksheet 'NonExistent' not found. Available worksheets in workbook (5 total)"
}
]
}
Common Error Messages
| Error Message | Cause | Solution |
|---|---|---|
Request is empty | Request object is null. | Provide a valid request object. |
Document is empty | Document object is null. | Provide a valid Excel document. |
Invalid worksheet selection | Worksheet name doesn't exist or index is out of range. | Use valid worksheet names, or valid 1-based indexes. |
Available worksheets in workbook (X total) | Informational message appended when worksheet selection validation fails. | Review worksheet names or indexes and use valid values from the X available worksheets listed. |
Cannot delete all worksheets. At least one worksheet must remain. | The combined selection matches every worksheet in the workbook. | Remove at least one worksheet from the deletion list so one sheet remains. |
How Do I Set Up Delete Worksheets in Power Automate?
- Add PDF4me → Delete Worksheets to your Power Automate flow.
- Map File Content and File Name from a previous action, such as SharePoint or OneDrive Get File Content.
- Set Worksheet Names, Worksheet Indexes, or both, to identify the sheets to remove.
- Run the flow. PDF4me deletes the matching worksheets and returns the updated workbook as
document, blocking the request if it would remove every sheet.
Should I Select Worksheets by Name or by Index?
Use Worksheet Names when the sheets to remove have stable, known names, such as "Sample1" or "Draft", since the selection stays correct even if the sheet order changes later. Use Worksheet Indexes when a flow generates workbooks with a predictable sheet order but variable names, remembering that indexes here are 1-based. Setting both deletes the union of the two selections, so overlap between them does not cause an error, it just removes that worksheet once.
Typical Setups
Workflow ExamplesCommon Power Automate flow patterns using Delete Worksheets from Excel.
- A flow triggers when a new employee record is created in the HR system.
- Get File retrieves the master expense-report template from a document library.
- Delete Worksheets runs with Worksheet Names set to "Sample1,Sample2,Instructions" to strip the placeholder sheets.
- The cleaned template is emailed to the new hire, keeping only the "Expenses" and "Receipts" tabs they need.
- A monthly report-generation flow completes and produces a working Excel file.
- Get File retrieves the report from SharePoint.
- Delete Worksheets removes the internal "Calculations", "RawData", and "Draft" tabs by name, leaving only "Summary" and "Charts".
- The finalized file is emailed to leadership without exposing internal working sheets.
- A recurrence trigger runs a quarterly archival flow on a rolling 12-month report.
- Get File retrieves the rolling report, which accumulates one worksheet per month.
- Delete Worksheets removes the oldest quarter's monthly tabs, identified by name (for example "Jan2026,Feb2026,Mar2026").
- The trimmed workbook is saved back to SharePoint, keeping the file size manageable.
Practical Tips
Cheat Sheet
| Field | Value |
|---|---|
| Action | Delete Worksheets |
| File Content | Mapped from a prior file-retrieval action |
| File Name | e.g. data.xlsx |
| Worksheet Names | Comma-separated, case-sensitive |
| Worksheet Indexes | 1-based, comma-separated |
| At least one required | Worksheet Names or Worksheet Indexes must be set |
| Both filled | Union of name matches and index matches |
| Safety check | Blocks deletion if it would remove every worksheet |
| Output | document (Base64 Excel), Success, Error Message, Errors |
Common Questions
Industry Use Cases & Applications
- Finance & Accounting
- Sales & Marketing
- Human Resources
- Operations & Manufacturing
- Project Management
- Education & Research
Finance & Accounting Use Cases
- Template Distribution: Remove sample worksheets from accounting templates before sending to new users
- Report Finalization: Delete calculation worksheets from financial reports before distribution
- Period Close: Remove prior-period worksheets from rolling monthly reports
- Audit Preparation: Delete internal review worksheets from audit deliverables
Sales & Marketing Use Cases
- Territory Cleanup: Remove inactive territory worksheets from sales reports
- Campaign Reports: Delete draft worksheets before sharing final campaign results
- Forecast Templates: Remove example worksheets from forecast templates before distribution
- Pricing Updates: Delete outdated pricing worksheets from rate sheets
Human Resources Use Cases
- Template Preparation: Remove sample-data worksheets from HR templates
- Benefits Enrollment: Delete previous-year worksheets from enrollment files
- Performance Reviews: Remove old review-period worksheets from templates
- Payroll Processing: Delete backup worksheets from finalized payroll files
Operations & Manufacturing Use Cases
- Production Reports: Remove draft worksheets from production summaries
- Inventory Cleanup: Delete discontinued-product worksheets
- Quality Control: Remove temporary QC worksheets from final reports
- Maintenance Logs: Delete archived maintenance worksheets
Project Management Use Cases
- Project Templates: Remove example worksheets from project templates
- Status Reports: Delete working-draft worksheets from client deliverables
- Resource Planning: Remove old allocation worksheets from resource files
- Budget Tracking: Delete previous-year worksheets from budget templates
Education & Research Use Cases
- Grade Book Cleanup: Remove old semester worksheets from grade books
- Course Templates: Delete sample-data worksheets from course templates
- Research Data: Remove preliminary-analysis worksheets from final data files
- Student Rosters: Delete graduated-class worksheets from master rosters