Skip to content

Google Sheets — Clear range

Type: googlesheets-clear-range  ·  Package: Google Sheets Activities v1.0.5  ·  Output: —

Clears the content of a range of cells. Useful to wipe old data before writing new data, so no stale rows are left below. It removes only the values (and formulas), not the formatting: colors, borders and widths are kept.

Empties the cells of range in the sheet sheet (the first one if empty) with one call to Google. Clearing a range that is already empty is not an error. The change is immediate and cannot be undone from the robot (it can from the sheet’s version history).

ParameterTypeDefaultDescription
rangestring—Range to clear in A1 notation: A1:Z100, A:Z (whole columns), 2:1000 (rows).
ParameterTypeDefaultDescription
sessionZoanGoogleSheetsSession—Session from Google Sheets — Open. Inside Open’s body it is inherited and you can leave it empty.
sheetstring—Sheet name. If empty, the first sheet is used.

This activity does not return a value.

MessageCause and fix
'range' is required.range is empty or its expression returned null.
No Google Sheets session available. Provide 'session' from a googlesheets-open activity, or place this activity inside the Open activity's body …The activity is outside Open’s body and received no session. Move it inside the body or pass the saved session.
The service sheets has thrown an exception. HttpStatusCode is …Google rejected the call: missing sheet or range, no access, expired token or quota exceeded. See Google API errors.

Clear the data (keeping the titles in row 1) and write it again:

Google Sheets — Clear range session = book sheet = "Results" range = "A2:Z"
Google Sheets — Write range session = book sheet = "Results" range = "A2" values = fresh