Last active
April 30, 2020 17:26
-
-
Save redbar0n/b08f2b25b5df7bec935bbf00e9454296 to your computer and use it in GitHub Desktop.
Google Sheets - How to format cells through code in Google Sheets. Option 1: Automatically when the spreadsheet opens.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This does not set the color of a user-selected cell like using getActiveCell does, | |
// but it necessarily relies on getActiveSheet(), since ranges are defined as referencing cells within sheets. | |
function setBackgroundOfScriptDeclaredCell() { | |
var sheet = SpreadsheetApp.getActiveSheet(); | |
var range = sheet.getRange("A1"); | |
range.setBackground("red"); | |
} | |
// Will run when user opens/refreshes spreadsheet. | |
function onOpen() { | |
setBackgroundOfScriptDeclaredCell(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment