I'm sorry to bother with such a trivial issue, but I'm at my wit's end here. I'm using code that was posted online to clear rows that have a checked check box, which should be easy as pie. Unfortunately, every single time I ty to save the script, I get an error "Syntax error: SyntaxError: Unexpected token 'if' line: 8 file: Code.gs" I am all but certain I have the brackets and lines all right, and when I'm typing out the code I use the "if" function that pops up, yet it simply will not recognize the if statement. Any suggestions are welcome, and again I apologize for something so damned trivial. The incredibly simple and tiny script is below:
function clearSelected() {
const ss = SpreadsheetApp.getActiveSpreadsheet()
const ws = ss.getActiveSheet()
const colAdata = ws.getRange("A:A").getValues()
for(let i = colAdata.length-1;i >= 0;i --)(
if (colAdata[i][0] === true){
ws.deleteRow(i 1)
}
)
}
CodePudding user response:
Try to delete the space between the i and the minuses
CodePudding user response:
You have a regular parenthesss ((
and )
) surrounding your for
block instead of curly braces ({
and }
):
for(let i = colAdata.length-1;i >= 0;i --) { // Here
if (colAdata[i][0] === true) {
ws.deleteRow(i 1)
}
} // and Here