First, let me clarify that this is my first time doing anything with Google Apps Script or javascript in general. I'm trying to create a function that adds checkboxes to all cells in a column which is easy enough and I've already managed this.

I do, however, have a caveat:

  • I press the button I've assigned my function to and it applies a checkbox to every cell in the desired row.
  • I want to create an exception to this function for all cells containing a certain character (in this case, "¬".)
function addLine () {

SpreadsheetApp.getActive().getSheetByName("RP Checklist")


This is what I have so far. How would I go about creating the desired exempt cells?

  • Welcome to Web Applications Stack Exchange. It is unclear whether you want to insert checkboxes in column A only, or in multiple columns across rows that match your criteria. Dec 12, 2022 at 22:28
  • Hi there! I'd like to only insert checkboxes into column A only.
    – Mmm
    Dec 12, 2022 at 23:33
  • Try the code in the answer below and comment back. Dec 13, 2022 at 8:34

1 Answer 1


You will have to insert those checkboxes one by one, like this:

function insertCheckBoxesAllTheWayDownExceptWhenTheCellContainsTheNotSign() {
  const range = SpreadsheetApp.getActive().getRange('RP Checklist!A5:A');
  const values = range.getDisplayValues().flat();
  values.forEach((value, rowIndex) => {
    if (!value.includes('¬')) {
      range.offset(rowIndex, 0, 1, 1)
  • Amazing! Works perfectly. Thank you very much.
    – Mmm
    Dec 13, 2022 at 12:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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