mardi 3 septembre 2019

How to make if statement based on value in cell work for Google Script?

I am trying to write a script which will automatically sort based on value in specific cell, it does sort when there is no if statement, what I am doing wrong?

function onEdit(e) {
 var ss = SpreadsheetApp.getActiveSpreadsheet();
 var sheet = ss.getSheetByName("Sheet1")

 if(sheet.getRange(18,3).getValue()=='TRUE'){
 var range = sheet.getRange("B10:C17");  
 range.sort({column: 3, ascending: true});
  }
}

This is how the table looks like Table example link

I want the table to sort when tick-box is active so the tick-box value equals TRUE.

Aucun commentaire:

Enregistrer un commentaire