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

No tagged tutorials yet. Fetch Apps Script from the harvest table and this page fills automatically.

Related blog posts

Written guides about SpreadsheetApp.setBackground().

Browse the blog