Forum Discussion
Find and Replace within a known range using typescript in the Script Editor
- Jun 16, 2022
Hi Jrolle2022
I'm not a JavaScript dev. and don't have access to TypeScript with my 365 subscription so can't test the following that's only my understanding after reading the doc.
The Range interface has method replaceAll and after looking at the examples given for the ReplaceCriteria the following should work:
function main(workbook: ExcelScript.Workbook) { let sheet = workbook.getActiveWorksheet(); let breakCol = sheet.getRange("O2:O25"); breakCol.replaceAll("\n", ",", { completeMatch: false }); }or, given that completeMatch defaults to false:
function main(workbook: ExcelScript.Workbook) { let sheet = workbook.getActiveWorksheet(); let breakCol = sheet.getRange("O2:O25"); breakCol.replaceAll("\n", ","); }Hope this helps a bit & your feedback will be appreciated, whatever it is
(It's my understanding that TypeScript issues should be raised at stackoverflow)
Lorenzo You are amazing! That was just what I needed. I figured the "find" method wasn't going to cut it, but really wasn't aware of a programmatic alternative. Thanks a ton for your help!
Glad this worked as per the doc. Thanks for providing feedback & marking the solution (can help those who search this site)
Nice day...