Removes only cell values from a range, keeping formatting.
class SpreadsheetApp method .clearContent()
SpreadsheetApp is the Apps Script service.
.clearContent() is the method name you will see after a dot in your code.
What it does
Why it's used
- Empty cells but keep colors and borders intact.
- Refresh data rows without rebuilding the whole layout.
Common errors
- Forgetting parentheses on clearContent. Write SpreadsheetApp.clearContent(), not SpreadsheetApp.clearContent or clearContent by itself.
- Skipping dots between chained calls. Each step needs a dot, like SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Data').clearContent().
- Adding spaces where they do not belong. Write SpreadsheetApp.clearContent(), not SpreadsheetApp .clearContent(), SpreadsheetApp.clearContent (), or SpreadsheetApp . clearContent().
- Wrong capitalization. Use SpreadsheetApp and clearContent, not spreadsheetapp or clearcontent.
1 Snippets using this method
Explore
Related methods
-
.clearFormat()
Removes only formatting from a range, keeping values.
-
.clear()
Removes values, formatting, and notes from a range.
-
.getDisplayValues()
Reads the formatted text shown in every cell in a range.
-
.deleteSheet()
Removes a sheet tab from the spreadsheet.
-
.setWrap()
Turns text wrapping on or off for cells in a range.
More Apps Script
1 Better Sheets tutorials
Automatically Clear Content | Refresh Reuse Recycle Templates
Related blog posts
Written guides about SpreadsheetApp.clearContent().
What's Better Than Google Sheets?
Nothing is better than Google Sheets. You just need to learn more about the unlimited power of Google Sheets. Functions, Formulas, Apps Script and more.
Read post →Protect Your Formulas from Accidental Deletion in Google Sheets
Ever spent hours crafting the perfect formula in Google Sheets, only to accidentally delete it? It's a frustrating experience that can derail your productivity. Fear not! In this guide, we'll unveil some clever tricks to safeguard your hard work.
Read post →How to Use Google Sheets as a Website Database
Did you know you can use Google Apps Script to turn a Google Sheet into a free, auto-syncing database for your website? This guide shows you exactly how to set it up. You’ll prepare your spreadsheet, write a few lines of code and publish your site. Don’t worry if you’re not a developer, we’ll walk you through it. Why Use Google Sheets as a Database? For small projects, Google Sheets offers many advantages over traditional databases: * Free hosting and storage * Easy to edit data without...
Read post →