Last active
April 9, 2021 21:13
-
-
Save zaemyung/0750cd0d1f2f5bc1826d1e2ae3cad94f to your computer and use it in GitHub Desktop.
Google App macro script for coloring cells that are selected disjointly in Google Sheets
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
function colorSelectedRangeGreen() { | |
var sel = SpreadsheetApp.getActive().getSelection().getActiveRangeList().getRanges(); | |
for(var i = 0; i < sel.length; i++){ | |
var cell = sel[i].setBackground("#93c47d"); | |
} | |
} | |
function colorSelectedRangePink() { | |
var sel = SpreadsheetApp.getActive().getSelection().getActiveRangeList().getRanges(); | |
for(var i = 0; i < sel.length; i++){ | |
var cell = sel[i].setBackground("#ffcccc"); | |
} | |
} | |
function colorSelectedRangeBlue() { | |
var sel = SpreadsheetApp.getActive().getSelection().getActiveRangeList().getRanges(); | |
for(var i = 0; i < sel.length; i++){ | |
var cell = sel[i].setBackground("#b3d9ff"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To use the macros in Google Sheets:
Tools
->Script editor
-> Paste the codes.Tools
->Macros
->Import
-> Select the functions.Tools
->Macros
->Manage macros
.