Skip to main content

Delete Rows from Excel in Power Automate

PDF4me Delete Rows from Excel is a Power Automate action that removes one or more row ranges from an Excel worksheet using comma-separated range syntax. Use it to trim header rows, drop expired records, or clear sample data whenever a flow hands it a workbook and a range string, returning a cleaned Excel file ready for the next step.

What this action does

PDF4me Delete Rows from Excel takes an Excel file plus a Row Ranges string and removes exactly those rows from the target worksheet. Ranges can mix single rows and hyphenated spans in one request, and PDF4me always deletes from the highest row number down so earlier ranges in the same call are never shifted out of place.

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 row deletion service from your flow.

Important Facts You Should Not Miss

Row Ranges is one comma-separated string
Combine single rows and hyphenated ranges in one field, for example 1-5,10,15-20. Optional surrounding brackets like [1-5] are accepted the same as 1-5.
Deletion always runs bottom-to-top
PDF4me removes the highest row numbers first automatically, so the other ranges in the same request are never shifted out of position by an earlier deletion.
Worksheet Name is optional
Leave it blank to target the first worksheet in the workbook, or enter the exact, case-sensitive name to target a specific sheet.
Power Automate PDF4me Excel Delete Rows action showing File Content, File Name, Worksheet Name, and Row Ranges fields

Map File Content and File Name from a prior action, set Worksheet Name if the target isn't the first sheet, then enter Row Ranges.

Parameters

Required: File Content, File Name, and Row Ranges must always be provided. Worksheet Name is optional and defaults to the first worksheet.

ParameterRequiredWhat it doesExample
File ContentRequiredBase64 or buffer content of the source Excel file, typically mapped from a prior action like SharePoint Get File Content or OneDrive.[File Content from Get File]
File NameRequiredName of the Excel file including its extension, used for processing and naming the output.data.xlsx
Worksheet NameOptionalExact, case-sensitive name of the worksheet to delete rows from. Blank defaults to the first worksheet (index 0).Sheet1
Row RangesRequiredComma-separated row ranges in 1-based format. A single number deletes one row, a hyphenated pair deletes a span, and multiple entries can be combined, for example 1-5,10,15-20.1-5,10,15-20

What Does Delete Rows Return?

FieldTypeWhat it contains
documentBase64The Excel document with the specified rows removed.
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 with Code and Message, empty when Success is true.

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.
Row ranges are requiredRowRanges is null or an empty string.Provide a valid row range specification.
Invalid worksheet selectionWorksheetName doesn't exist in the workbook.Use an existing worksheet name.
Invalid start row {row}. Row numbers must be positive.Row number is less than 1, such as "0-5" or "-1".Use row numbers of 1 or greater (1-based indexing).
Row {row} exceeds maximum data row ({maxRow})Row number is greater than the worksheet's data row count.Use row numbers within the valid range, 1 to maxRow.
Invalid range {start}-{end}: End row cannot be less than start rowEnd row is smaller than start row, such as "10-5".Make sure the end row is greater than or equal to the start row.
Invalid row range formatMalformed range string that couldn't be parsed.Check the syntax, use commas and hyphens correctly.

How Do I Set Up Delete Rows in Power Automate?

  1. Add PDF4meDelete Rows from Excel 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 Name if the target isn't the first worksheet, otherwise leave it blank.
  4. Enter Row Ranges as a comma-separated string, for example 1-5,10,15-20.
  5. Run the flow. Rows are deleted bottom-to-top automatically, and the cleaned file returns as document.

Typical Setups

Workflow ExamplesCommon Power Automate flow patterns using Delete Rows from Excel.
Report header and footer cleanup
  1. A flow trigger fires when an internal report is marked ready for a client.
  2. Get File Content retrieves the report from SharePoint.
  3. Delete Rows from Excel runs with Row Ranges set to the internal header and footer rows, for example "1-3,96-100".
  4. The cleaned file is emailed to the client and the original is archived separately.
Scheduled transaction log trimming
  1. A recurrence trigger runs a monthly archival flow.
  2. Get File Content retrieves the Excel transaction log from SharePoint.
  3. A prior step identifies rows older than the retention window and builds a Row Ranges string dynamically.
  4. Delete Rows from Excel removes those rows, and the trimmed log is saved back to SharePoint.
Template sample data removal
  1. A new-hire onboarding flow starts in the HR system.
  2. Get File Content retrieves the expense report template from a templates library.
  3. Delete Rows from Excel removes the sample rows with Row Ranges set to "2-10" and Worksheet Name set to "Expenses".
  4. The clean template is emailed to the new employee with row 1 headers intact.

Practical Tips

Count rows before building the range string
Row Ranges rejects any row number past the worksheet's data row count, so confirm the row count first if you are constructing ranges dynamically from another action's output.
Combine ranges in one call instead of looping
A single Row Ranges string like "1-5,10,15-20" deletes multiple spans in one action run, which is simpler to maintain than chaining several Delete Rows actions.
Match Worksheet Name 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.
Brackets around a range are optional
Both "1-5" and "[1-5]" are accepted for the same range, so either format works if the string is being generated by another system.
Don't worry about deletion order in the input
You can list ranges in any order in Row Ranges. PDF4me sorts and deletes from the highest row number down automatically to avoid index shifting.

Cheat Sheet

FieldValue
ActionDelete Rows from Excel
File ContentMapped from a prior file-retrieval action
File Namee.g. data.xlsx
Worksheet NameBlank = first worksheet, or exact case-sensitive name
Row Ranges format1-based, comma-separated: "1-5,10,15-20"
Deletion orderBottom-to-top automatically, no action needed
Outputdocument (Base64), Success, Error Message, Errors

Common Questions

How do I delete rows in Excel using Power Automate?+
Add the PDF4me Delete Rows from Excel action, map File Content and File Name from a prior action, set Worksheet Name if needed, and provide Row Ranges as a comma-separated string such as 1-5,10,15-20. Running the flow returns the Excel file with those rows removed.
What format does Row Ranges use?+
Row Ranges is a comma-separated string using 1-based row numbers. Use a single number for one row, a hyphenated pair for a range, and commas to combine several, for example 1-5,10,15-20 deletes rows 1 through 5, row 10, and rows 15 through 20.
Why are rows deleted bottom-to-top instead of top-to-bottom?+
Deleting from the bottom up prevents index shifting. If rows were removed top-to-bottom, every deletion would shift the remaining row numbers up by one, causing later ranges in the same request to target the wrong rows. See <a href="https://learn.microsoft.com/en-us/office/vba/api/excel.range.delete" target="_blank" rel="noopener noreferrer">Microsoft's Excel Range.Delete reference</a> for how row shifting works natively in Excel.
What happens if a row range is invalid?+
The action returns Success as false with an ErrorMessage describing the problem, for example a row number that exceeds the worksheet data row count, or a range where the end row is smaller than the start row. No rows are deleted when the request fails validation.
Can I delete rows from a worksheet other than the first one?+
Yes. Set Worksheet Name to the exact, case-sensitive name of the target worksheet. Leaving it blank defaults to the first worksheet in the workbook. 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.

Industry Use Cases & Applications

Finance & Accounting Use Cases

  • Transaction Cleanup: Delete old or void transaction rows from accounting logs
  • Period Close: Remove temporary calculation rows after month-end close
  • Report Distribution: Delete internal notes and review comments from client reports
  • Budget Templates: Remove previous year sample data from new budget templates

Same Task on Other Platforms

Get Help