Sets the background color of cells in a range.
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
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.
Snippets using this method
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.
More Apps Script
Better Sheets tutorials
Brighten Up Your Checklist Automatically
Create an Internal Google Sheets Add-on
Create Your Own NIGHT Mode (like PRIDE)
Explore Readable Hex Codes
Google Maps Scraper for Outreach
Introducing SheetFools
Visicalc 2023 Design Walkthrough
Related blog posts
Written guides about SpreadsheetApp.setBackground().
How to Change Border Colors in Google Sheets with Apps Script
Recolor only the borders you already have in Google Sheets, with a hex code prompt, a reset button, and a custom menu. The real Apps Script from Big Year Premium, explained step by step.
Read post →Google Sheets Green Color Hex Code
Google Sheets Green Color Hex Code! Dive into #0F9D58, Google's vibrant shade of Green. The green color code you'll want to use in all your designs if you're google sheets adjacent.
Read post →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 →