Currently, my script is performing the task of hiding three columns for tabs in a workbook that start with "TRI". However, the execution speed is quite sluggish. I am seeking suggestions on how to optimize and enhance the performance. If possible, please provide examples of code to demonstrate the correct syntax using an array or by declaring tName/checkTRI outside of the loop. Whenever I attempt these modifications, the code breaks.
function main(workbook: ExcelScript.Workbook) {
let ws = workbook.getWorksheets();
for (let w of ws) {
let tName = w.getName();
let checkTRI = tName.substring(0, 3);
if(checkTRI=="TRI"){
w.getRange("F:F").setColumnHidden(true);
w.getRange("G:G").setColumnHidden(true);
w.getRange("H:H").setColumnHidden(true);
}
}
}