Forum Discussion
djmitz6
Feb 21, 2024Copper Contributor
Excel Script ReplaceAll ignore formulas
Greetings, I'm currently running an excel script where I am replacing all single quote characters with two single quote characters consecutively so that I can push the data in a table over to an ...
SergeiBaklan
Feb 22, 2024MVP
We may use console.log here, but no sense if the script runs by Power Automate.
You variant returns
${sheet} has no UsedRange
if change on
console.log( sheet.getName() + ' is empty')
it returns something like
Sheet3 is empty
===
Yes, without FALSE condition it returns
Line #13: ':' expected.
However, if instead of shortened "if" to use regular "if" we may skip it
function main(workbook: ExcelScript.Workbook) {
workbook
.getWorksheets()
.forEach(sheet => {
if( sheet.getUsedRange() !== undefined ) {
sheet
.getUsedRange()
.getSpecialCells(ExcelScript.SpecialCellType.constants)
.getAreas()
.map(a => a.getUsedRange().replaceAll("'", "''", {}))
}
} )
}
Lorenzo
Feb 22, 2024Silver Contributor
We may use console.log here, but no sense if the script runs by Power Automate
Sure, that was just to check I understood we were making an IF