sheet/deleteRowsOrColumns FormID SH06
Delete a contiguous range of rows or columns from a sheet tab by 0-based start index and count. Remaining data shifts up (for rows) or left (for columns) to fill the gap. This operation is irreversible.
0-based indexing:
StartIndex is 0-based. Row 1 (the header row in most sheets) is index 0. Row 2 (the first data row) is index 1. This differs from the 1-based row numbers used in sheet/clear and sheet/get. Always double-check your index calculation before executing.
When to Use
- HR — remove terminated employee rows: When an employee is terminated, a workflow identifies the employee's row number (via
sheet/getwith a filter and row index tracking), then callssheet/deleteRowsOrColumnsto physically remove that row. The remaining employee records shift up — no blank rows remain in the roster. - Operations — remove completed task rows: A workflow runs nightly and deletes all rows in the "Active Tasks" sheet where status is "Completed". This keeps the active view clean without relying on filters, which some sheet consumers (dashboards, pivot tables) do not support.
- Finance — remove voided invoice rows: When an invoice is voided in the ERP, a workflow removes its row from the "Open Invoices" sheet so downstream reports and totals reflect only live invoices.
- Data cleanup — remove deprecated columns: After a schema change, a workflow removes a deprecated column from a sheet (using
Dimension: Columns). All data to the right of the removed column shifts left, and all downstream formulas that reference column letters are updated automatically by Sheets. - Batch cleanup — remove header rows from imported data: When data is imported from a third-party CSV with multiple non-data header rows, a workflow uses
deleteRowsOrColumnsto remove the extra header rows (e.g. rows 0 through 2) before further processing, leaving a clean single-header structure.
Configuration
| Field | Required | Description |
|---|---|---|
CredentialId | Required | Integer ID referencing a stored Google credential in the BizFirst Credentials Manager. |
SpreadsheetId | Required | The Google Sheets spreadsheet ID from the URL. |
SheetName | Required | Exact name of the target tab. Case-sensitive. |
Dimension | Optional | Enum: Rows | Columns. Default Rows. Whether to delete rows or columns. Rows: removes the specified rows and shifts all rows below upward. Columns: removes the specified columns and shifts all columns to the right leftward. |
StartIndex | Required | Integer. 0-based index of the first row or column to delete. Row 1 (Google Sheets row number 1) = index 0. Row 2 = index 1. Column A = index 0. Column B = index 1. |
Amount | Required | Integer. Number of rows or columns to delete, starting from StartIndex. The deleted range covers StartIndex through StartIndex + Amount - 1 (inclusive). Must be at least 1. |
Row index calculation: To delete row number N (in human/Sheets terms), set
StartIndex = N - 1. To delete rows 5 through 8 (4 rows), set StartIndex = 4 (row 5 minus 1) and Amount = 4.
Validation Errors
| Error Code | Cause |
|---|---|
VAL_MISSING_SPREADSHEET_ID | SpreadsheetId is empty or whitespace. |
VAL_MISSING_SHEET_NAME | SheetName is empty or whitespace. |
VAL_MISSING_START_INDEX | StartIndex is not provided. |
VAL_MISSING_AMOUNT | Amount is not provided or is less than 1. |
VAL_INVALID_START_INDEX | StartIndex is negative. |
VAL_RANGE_OUT_OF_BOUNDS | The specified range exceeds the number of rows or columns in the sheet. |
SHEET_NOT_FOUND | The specified SheetName does not exist in the spreadsheet. |
Output Fields
| Field | Type | Description |
|---|---|---|
dimension | string | "Rows" or "Columns" — echoed from the request. |
startIndex | integer | Echoed StartIndex from the request. |
endIndex | integer | Computed as StartIndex + Amount (exclusive end index, consistent with Google Sheets API range semantics). |
deletedCount | integer | Number of rows or columns that were deleted. Equal to Amount. |
sheetId | integer | Internal Google sheet ID of the tab that was modified. |
spreadsheetId | string | Echoed spreadsheet ID. |
status | string | "success". |
resource | string | Always "sheet". |
operation | string | Always "deleteRowsOrColumns". |
Sample Configuration
// Delete rows 5 through 7 (3 rows, 0-based index 4)
{
"resource": "sheet",
"operation": "deleteRowsOrColumns",
"CredentialId": 12,
"SpreadsheetId": "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgVE2upms",
"SheetName": "Active Tasks",
"Dimension": "Rows",
"StartIndex": 4,
"Amount": 3
}
Sample Output
{
"dimension": "Rows",
"startIndex": 4,
"endIndex": 7,
"deletedCount": 3,
"sheetId": 924830127,
"spreadsheetId": "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgVE2upms",
"status": "success",
"resource": "sheet",
"operation": "deleteRowsOrColumns"
}
Expression Reference
Assuming this node is named deleteCompletedRows in the workflow:
| Expression | Returns | Description |
|---|---|---|
{{ $output.deleteCompletedRows.deletedCount }} | integer | Number of rows (or columns) deleted. |
{{ $output.deleteCompletedRows.dimension }} | string | "Rows" or "Columns" — echoed from config. |
{{ $output.deleteCompletedRows.startIndex }} | integer | 0-based start index that was used. |
{{ $output.deleteCompletedRows.endIndex }} | integer | Exclusive end index (startIndex + amount). |
{{ $output.deleteCompletedRows.sheetId }} | integer | Internal Google sheet ID of the modified tab. |
Node Policies & GuardRails
- 0-based index — always verify: Confusion between 0-based (this node) and 1-based (Sheets UI) indexing is the most common source of errors with this operation. Off-by-one errors delete the wrong rows. Use a Code node upstream to compute and log the index before calling this node.
- Row index shift after delete: After rows are deleted, all row indices below the deleted range shift upward. If you are deleting multiple non-contiguous rows, process from bottom to top to avoid index drift — delete the highest-index rows first.
- Irreversible: Row and column deletions cannot be undone via the API. Only Google Sheets' version history can recover deleted rows (available for 30 days). Guard this node with an environment flag or approval step in production workflows.
- Use sheet/get first: When deleting rows based on content (e.g. "delete all rows where Status = Completed"), call
sheet/getfirst to identify the row numbers, then map them to 0-based indices and call this node. Store the row position metadata during the get phase. - Column deletion and formula references: Deleting a column shifts all subsequent columns left and updates cell references in formulas within the same sheet automatically. However, external references (from other sheets or workbooks) pointing to deleted columns will break. Verify no cross-sheet formula dependencies before deleting columns.
- Quota: One write request per delete operation regardless of the number of rows/columns in the range.
Workflow Examples
Example 1 — Remove Terminated Employee Row
// Trigger: Webhook from HRIS (employee terminated)
// Step 1: Find the employee's row number
// Node 1 — sheet/get (findEmployee)
{
"resource": "sheet", "operation": "get",
"CredentialId": 12,
"SpreadsheetId": "{{ $env.HR_SHEET_ID }}",
"SheetName": "Employees",
"Filters": [{ "Column": "EmployeeId", "Operator": "Equals", "Value": "{{ $json.employeeId }}" }],
"ReturnFirstMatch": true
}
// Node 2 — Code node: compute row index
// The row index in the sheet = HeaderRow(1) + FirstDataRow offset + position in results
// Assumes rows are ordered and we track rowIndex from the get response metadata
// Output: rowIndex (0-based)
// Node 3 — sheet/deleteRowsOrColumns (removeEmployee)
{
"resource": "sheet", "operation": "deleteRowsOrColumns",
"CredentialId": 12,
"SpreadsheetId": "{{ $env.HR_SHEET_ID }}",
"SheetName": "Employees",
"Dimension": "Rows",
"StartIndex": "{{ $output.computeIndex.rowIndex }}",
"Amount": 1
}
Example 2 — Remove Extra CSV Header Rows
// Imported CSV data has 3 header/metadata rows before real data
// Delete rows 1-3 (indices 0, 1, 2 — but we delete in one call: StartIndex=0, Amount=3)
{
"resource": "sheet", "operation": "deleteRowsOrColumns",
"CredentialId": 15,
"SpreadsheetId": "{{ $env.IMPORT_SHEET_ID }}",
"SheetName": "Import Buffer",
"Dimension": "Rows",
"StartIndex": 0,
"Amount": 3
}
// After this node: row 4 (old) becomes row 1 (new index 0)
Example 3 — Remove Deprecated Column
// Remove column D (index 3) — a deprecated "LegacyCode" field
{
"resource": "sheet", "operation": "deleteRowsOrColumns",
"CredentialId": 12,
"SpreadsheetId": "{{ $env.PRODUCTS_SHEET_ID }}",
"SheetName": "Products",
"Dimension": "Columns",
"StartIndex": 3,
"Amount": 1
}
// Column E shifts to D, column F shifts to E, etc.