Skip to main content

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.

Related Blog Posts
No blog post yet for this feature — coming soon.
In the meantime, browse the PDF4me blog for tutorials and workflows across every platform.
Visit the blog

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

Worksheet Indexes are 1-based here
Index 1 is the first worksheet, index 2 the second, and so on. This action uses 1-based indexing, unlike some other PDF4me Excel actions.
At least one worksheet must remain
A request that would delete every worksheet in the workbook is rejected with an error, since Excel requires at least one sheet.
Name and index selections combine as a union
If both fields are filled, every worksheet matching either list is deleted once, not just the ones matching both.
Power Automate PDF4me Excel Delete Worksheets action showing File Content, File Name, Worksheet Names, and Worksheet Indexes fields

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.

ParameterRequiredWhat it doesExample
File ContentRequiredBase64 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 NameRequiredName of the Excel file including its extension, used for processing and output naming.data.xlsx
Worksheet NamesConditionalComma-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 IndexesConditionalComma-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?

FieldTypeWhat it contains
documentBase64Excel document with the specified worksheets deleted.
SuccessBooleantrue when the deletion completed, false if the request failed validation or processing.
Error MessageStringDescription of what went wrong, null when Success is true.
ErrorsArrayDetailed error entries, empty when Success is true.
{
"document": "[Base64 Excel Content with Worksheets Deleted]",
"Success": true,
"ErrorMessage": null,
"Errors": []
}

Common Error Messages

Error MessageCauseSolution
Request is emptyRequest object is null.Provide a valid request object.
Document is emptyDocument object is null.Provide a valid Excel document.
Invalid worksheet selectionWorksheet 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?

  1. Add PDF4meDelete Worksheets to your Power Automate flow.
  2. Map File Content and File Name from a previous action, such as SharePoint or OneDrive Get File Content.
  3. Set Worksheet Names, Worksheet Indexes, or both, to identify the sheets to remove.
  4. 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.
Template cleanup for new-hire onboarding
  1. A flow triggers when a new employee record is created in the HR system.
  2. Get File retrieves the master expense-report template from a document library.
  3. Delete Worksheets runs with Worksheet Names set to "Sample1,Sample2,Instructions" to strip the placeholder sheets.
  4. The cleaned template is emailed to the new hire, keeping only the "Expenses" and "Receipts" tabs they need.
Report finalization before distribution
  1. A monthly report-generation flow completes and produces a working Excel file.
  2. Get File retrieves the report from SharePoint.
  3. Delete Worksheets removes the internal "Calculations", "RawData", and "Draft" tabs by name, leaving only "Summary" and "Charts".
  4. The finalized file is emailed to leadership without exposing internal working sheets.
Scheduled archival worksheet cleanup
  1. A recurrence trigger runs a quarterly archival flow on a rolling 12-month report.
  2. Get File retrieves the rolling report, which accumulates one worksheet per month.
  3. Delete Worksheets removes the oldest quarter's monthly tabs, identified by name (for example "Jan2026,Feb2026,Mar2026").
  4. The trimmed workbook is saved back to SharePoint, keeping the file size manageable.

Practical Tips

Double-check the index base before mapping a value
Delete Worksheets uses 1-based indexes, so index 1 is the first sheet. Other PDF4me Excel actions use 0-based indexing; mixing the two up is the most common source of the wrong sheet being deleted.
Match Worksheet Names exactly, including case
Worksheet name comparison is case-sensitive. A mismatch returns an invalid worksheet selection error even if the name looks correct at a glance.
Always leave one worksheet standing
Build the deletion list so at least one sheet survives. Attempting to delete every worksheet fails outright rather than leaving an empty workbook.
Combining names and indexes extracts a union, not an intersection
If a worksheet matches either list, it is removed once. Use only one selection method if you need a fully predictable deletion set.
Read the error message for the available worksheet list
An invalid worksheet selection error includes the workbook's actual worksheet names or count, which is faster to debug against than guessing at a typo.

Cheat Sheet

FieldValue
ActionDelete Worksheets
File ContentMapped from a prior file-retrieval action
File Namee.g. data.xlsx
Worksheet NamesComma-separated, case-sensitive
Worksheet Indexes1-based, comma-separated
At least one requiredWorksheet Names or Worksheet Indexes must be set
Both filledUnion of name matches and index matches
Safety checkBlocks deletion if it would remove every worksheet
Outputdocument (Base64 Excel), Success, Error Message, Errors

Common Questions

How do I delete a worksheet from Excel in Power Automate?+
Add the PDF4me Delete Worksheets action, map File Content and File Name from a prior action, then set Worksheet Names, Worksheet Indexes, or both to choose which sheets to remove. The action returns the updated workbook with the matching worksheets deleted.
Are Worksheet Indexes 0-based or 1-based in Delete Worksheets?+
Worksheet Indexes are 1-based in this action, so index 1 refers to the first worksheet, index 2 to the second, and so on. This differs from some other PDF4me Excel actions, so check the field's placeholder text before mapping a value. See <a href="https://learn.microsoft.com/en-us/connectors/pdf4meconnect/" target="_blank" rel="noopener noreferrer">the PDF4me Power Automate connector reference</a> for the full action list.
What happens if I try to delete every worksheet in a workbook?+
The action blocks the request and returns an error, because a valid Excel workbook must always contain at least one worksheet. Adjust the Worksheet Names or Worksheet Indexes list so at least one sheet remains.
Can I select worksheets by name and by index in the same request?+
Yes. If both Worksheet Names and Worksheet Indexes are provided, the action deletes the union of the two selections, so any worksheet matching either list is removed once, even if it appears in both.
What if a worksheet name or index does not exist in the workbook?+
The action returns an invalid worksheet selection error naming the missing sheet, along with the worksheets actually available in the workbook. See <a href="https://learn.microsoft.com/en-us/office/vba/api/excel.worksheets" target="_blank" rel="noopener noreferrer">Microsoft's Worksheets collection reference</a> for how Excel itself models worksheet collections.

Industry Use Cases & Applications

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

Same Task on Other Platforms

Get Help