Forum Discussion
Jhowe82
May 16, 2024Copper Contributor
Excel Online...How to clear multiple cells across multiple tabs
I have been searching but unable to find an answer or solution I am new to all this Macro and Scripting stuff in Excel. But I have a Workbook that I was able to create a Macro to clear multiple ...
SergeiBaklan
May 16, 2024Diamond Contributor
For the Automate the script could be like
function main(workbook: ExcelScript.Workbook) {
const sheets = workbook
.getWorksheets()
const names = ["AUS", "DAL", "HOU"] //etc
const range = "B11:I16, B19:I24, B27:I32, B3:I8"
for( let sheet of sheets) {
if( names.includes( sheet.getName() ) ) {
sheet
.getRanges(range)
.getAreas()
.map( a=>a.clear(ExcelScript.ClearApplyTo.all) )
}
}
}
You may add the button which runs the script, with that script could be run by any user who has rights on workbook.
The only there is no interactivity, i.e. you can't ask for the confirmation like "Are you sure?"
Documentation is here Office Scripts documentation - Office Scripts | Microsoft Learn, details are if expand API reference->ExcelScript, like ExcelScript.Range interface - Office Scripts | Microsoft Learn