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

Removes only cell values from a range, keeping formatting.

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.

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.

Better Sheets tutorials

Automatically Clear Content | Refresh Reuse Recycle Templates

Automatically Clear Content | Refresh Reuse Recycle Templates

Create automatic functions to clear content.
ChatGPT Clone in Google Sheets Part 1

ChatGPT Clone in Google Sheets Part 1

In this tutorial, learn how to create a ChatGPT-like interface using Goo...
ChatGPT Clone in Google Sheets Part 2

ChatGPT Clone in Google Sheets Part 2

We fix the problem of OpenAI's API not remembering our last questions. A...
Daily Writer's Word Count Tracker

Daily Writer's Word Count Tracker

Walk through creating an awesome automatic word count tracker that's eas...
Expense Tracker Template with Data Entry Form Inside Sheets

Expense Tracker Template with Data Entry Form Inside Sheets

Create a data entry form for an expense tracker. Simple dashboard too wi...
Fast FAQS

Fast FAQS

New Tool for you: Fast FAQs. Create a quick 10 question FAQ for any new ...
How to Create AI Images From Google Sheets

How to Create AI Images From Google Sheets

Use the Open AI API and Dall-e-3 to create image in Sheets
How To Format Sheets for Notes

How To Format Sheets for Notes

Create sortable notes in Three ways.  1. By adding the original word ove...
Ultimate Prompt Writer and Prompt Rater

Ultimate Prompt Writer and Prompt Rater

Create a chat interface inside of Google Sheets using GPT-4. Insert rows...
Visicalc 2023 Design Walkthrough

Visicalc 2023 Design Walkthrough

Design walkthrough of VisiCalc 2023. Watch this if you'd like to see the...
Visicalc 2023 Quick Walkthrough

Visicalc 2023 Quick Walkthrough

This is a fun template I created for April 1st. Take a quick walk throug...

Related blog posts

Written guides about SpreadsheetApp.clearContent().

Browse the blog