Need Help Clearing Specific Cells in multiple tabs in Google Sheets Scripts

by Jonathan   Last Updated September 11, 2019 15:03 PM

I'm having trouble editing this code to get it to edit multiple sheets at the same time. It works for whatever is active, but I'd like to disable that and have it work on each tab named after each month and when I'm trying to use getSheetByName(), it doesn't seem to work. Here's the code that does work.

function onOpen() {   
SpreadsheetApp.getUi()  
.createMenu('Reset sheet')  
.addItem('Remove all metrics', 'userActionResetByRangesAddresses')  
.addToUi();
}

function userActionResetByRangesAddresses(){  
var sheet1 = SpreadsheetApp.getActiveSheet();  
var rangesAddressesList = ['D4:E53', 'I4:I53', 'M4:O53','D60:E109', 'I60:I109', 'M60:O109','D116:E165', 'I116:I165', 'M116:O165', 'D172:E221', 'I172:I221', 'M172:O221','D228:E277', 'I228:I277', 'M228:O277'];  
resetByRangesList_(sheet1, rangesAddressesList);  
}

function resetByRangesList_(sheet1, rangesAddressesList){   
sheet1.getRangeList(rangesAddressesList).clearContent();  
}  

Any help would be greatly appreciated!



Related Questions



How would you improve this google sheets roster?

Updated April 27, 2019 08:03 AM

Function OnEdit run slow and timeout error

Updated May 29, 2019 06:03 AM


Trying to figure out a Google Script

Updated June 12, 2019 09:03 AM