Currently building out a sheet and trying to add a button that has a script assigned to clear a range. I just cannot get it to work and I've tried a few things I found on SO but no luck. ranges I am trying to clear at the click of a button are A3:C32, G3:Q32. A3:C32 are text fields and G3:Q32 are checkbox fields that have conditional formatting. essentially user clicks the button and clears everything in mentioned ranges so they can refill the page without loosing conditioning through G3:Q32. Any ideas on what I can try?
CodePudding user response:
Clear Datavalidations and content
function clearall() {
const ss = SpreadsheetApp.getActive();
const sh = ss.getActiveSheet();
const rgl = sh.getRangeList(["A3:C32", "G3:Q32", "A3:C32", "G3:Q32"]).getRanges();
rgl.forEach(r => {
r.clearDataValidations().clearContent()
})
}