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.
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
No tagged tutorials yet. Fetch Apps Script from the harvest table and this page fills automatically.
Related blog posts
Written guides about SpreadsheetApp.setBackground().
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 →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 →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 →