Mar 27 2024 02:59 PM - edited Mar 27 2024 03:03 PM
1. First start with "ORANGE" -worksheet-, but I need switch to "BLACK" -worksheet-, to replace more information.
I tried with
a)
b)
// ORANGE -worksheet-
function main(workbook: ExcelScript.Workbook) {
let selectedSheet = workbook.getWorksheet("ORANGE");
// Replace all "A.REY" with "A. REY" on range H:H on selectedSheet
selectedSheet.getRange("H:H").replaceAll("A.REY", "A. REY", { completeMatch: false, matchCase: false });
// switch to "BLACK" -worksheet- I tried a) and b)
}
Mar 27 2024 05:17 PM - edited Mar 27 2024 07:55 PM
Why can't you just loop?
function main(workbook: ExcelScript.Workbook) {
let sheets = workbook.getWorksheets().filter(q => q.getName() === 'ORANGE' || q.getName() === 'BLACK');
sheets.forEach(q => {
q.getUsedRange().replaceAll("A.REY", "A. REY", { completeMatch: false, matchCase: false });
});
}
Mar 28 2024 10:08 AM
Nice solution. I'd only not to hardcode sheet names within formula, something like
function main(workbook: ExcelScript.Workbook) {
const names = ["BLACK", "ORANGE"]
workbook.getWorksheets()
.filter( q => names.includes(q.getName()))
.map( w => w.getRange("H:H").getUsedRange()
.replaceAll("A.REY", "A. REY",
{ completeMatch: false, matchCase: false }
)
)
}
Also better the range name to move outside if only only we won't apply to entire used range within the sheet.
Mar 28 2024 05:35 PM
Mar 29 2024 05:47 AM
Lot of technologies involved. C#, Rider, Linq, TypeScript and finally Excel. Impressive!
Mar 29 2024 06:31 AM
Mar 29 2024 07:13 AM
AFE could help a bit, now it's even with kind of debugger. Not an IDE, but compare to formula bar that's a great progress.
Mar 29 2024 08:06 AM