class SpreadsheetApp method .setBackground()

SpreadsheetApp is the Apps Script service.

.setBackground() is the method name you will see after a dot in your code.

What it does

Sets the background color of cells in a range.

Why it's used

  • Color-code rows green for paid, red for overdue.
  • Highlight outliers after a data quality check.

Common errors

  • Forgetting parentheses on setBackground. Write SpreadsheetApp.setBackground(), not SpreadsheetApp.setBackground or setBackground by itself.
  • Skipping dots between chained calls. Each step needs a dot, like SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Data').setBackground().
  • Adding spaces where they do not belong. Write SpreadsheetApp.setBackground(), not SpreadsheetApp .setBackground(), SpreadsheetApp.setBackground (), or SpreadsheetApp . setBackground().
  • Wrong capitalization. Use SpreadsheetApp and setBackground, not spreadsheetapp or setbackground.

Explore

Related methods

  • .setFontColor()

    Sets the text color of cells in a range.

  • .activate()

    Makes a sheet or range the active selection.

  • .setWrap()

    Turns text wrapping on or off for cells in a range.

  • .getRange()

    Returns a range of cells by A1 notation or row and column numbers.

  • .clear()

    Removes values, formatting, and notes from a range.

Better Sheets tutorials

Brighten Up Your Checklist Automatically

Brighten Up Your Checklist Automatically

Create a cool function that brightens your sheet background from white t...
Create an Internal Google Sheets Add-on

Create an Internal Google Sheets Add-on

The entire process to create and publish a Google Sheets Add-on internal...
Create Your Own NIGHT Mode (like PRIDE)

Create Your Own NIGHT Mode (like PRIDE)

Create easter eggs in your sheets.
Explore Readable Hex Codes

Explore Readable Hex Codes

Welcome to the captivating world of Readable Hex Codes! In this video, w...
Google Maps Scraper for Outreach

Google Maps Scraper for Outreach

Get this fun template to search on google maps via API, and quickly mess...
Introducing SheetFools

Introducing SheetFools

Free google sheets automations pranks you can use right now. Launching p...
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.setBackground().

Browse the blog