0

Trying to add checkbox format to a column using Google Apps Script to this working formula

sales.getRange("I2").setFormula("=IF(COUNTIF(B:B,B2)=COUNTIFS(B:B,B2,E:E,TRUE),TRUE)");      
    var fillDownRange = sales.getRange (2, 9, salesLR);
           sales.getRange("I2").copyTo(fillDownRange);

Tried doing it this way without success:

sales.getRange("I2").setFormula("=IF(COUNTIF(B:B,B2)=COUNTIFS(B:B,B2,E:E,TRUE),TRUE)");      
var fillDownRange = sales.getRange (2, 9, salesLR);
       sales.getRange("I2").copyTo(fillDownRange).newDataValidation().requireCheckbox().build();

Also tried this without succss:

sales.getRange("I2").setFormula("=IF(COUNTIF(B:B,B2)=COUNTIFS(B:B,B2,E:E,TRUE),TRUE)");      
      var fillDownRange = sales.getRange (2, 9, salesLR);
      sales.getRange("I2").copyTo(fillDownRange).insertCheckboxes();
1

This has ben solved. I was targeting the wrong column, solution was:

sales.getRange (2, 5, salesLR).insertCheckboxes();
sales.getRange (2, 6, salesLR).insertCheckboxes();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.