To multi-select a number of ranges and change the color:
var sheet = SpreadsheetApp.getActiveSheet();
var rangeList = sheet.getRangeList(['A1:C1','A3:C3','A10','C10']);
sheet.setActiveRangeList(rangeList).setBackground("red");
If you want to type a list in a dialog box:
function promptRangesList() {
var ui = SpreadsheetApp.getUi();
var response = ui.prompt('Comma-separated ranges list', 'E.g.: A1:C1,A3:C3,A10,C10 or C3,C7,C17,C56', ui.ButtonSet.OK_CANCEL);
Logger.log(response.getSelectedButton());
// Process the user's response.
if (response.getSelectedButton() == ui.Button.OK) {
if (response.getResponseText()!=='') {
var list = response.getResponseText().split(',');
Logger.log(list);
var rangeslist = SpreadsheetApp.getActiveSheet().getRangeList(list).setBackground("red");
Logger.log(rangeslist);
rangeslist.activate();
} else {
Logger.log('getResponseText empty');
}
} else if (response.getSelectedButton() == ui.Button.CANCEL) {
Logger.log('CANCELED');
} else {
Logger.log('The user clicked the close button in the dialog\'s title bar.');
}
}
Reference:
Class RangeList - Selects the list of Range instances
Class Sheet - Sets the specified list of ranges as the active ranges in the active sheet.
Prompt dialogs - A prompt is a pre-built dialog box that opens inside a Google Docs, Sheets, or Forms editor.