I'm trying to make a script for Google Spreadsheets (which is my first time), by clearing a range of some cells.
So: for example I want to clear D5:D12
but not D13
and D14
, but then again I want to clear D15:D20
, but not D21, but
D22:D30` must be cleared (and it goes on like this all over the sheet).
All I have now is this:
function onOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var menubuttons = [ {name: "Clear Cells", functionName: "clear1"} ];
ss.addMenu("Functions", menubuttons);
}
function clear1() {
var sheet = SpreadsheetApp.getActive().getSheetByName('Blad1');
sheet.getRange('D5:D12').clearContent(),
sheet.getRange('D15:D20').clearContent(),
sheet.getRange('D22:D30').clearContent();
}
Hope you can help me to make this more easier. Because it's a lot of work to specify each range.
btw: all these cells are colored (orange color), is there a way the clear a specific color maybe?