Home > Net >  To Copy data from specific cell to another sheet using a checkbox(turn false when task is done)
To Copy data from specific cell to another sheet using a checkbox(turn false when task is done)

Time:04-02

Need to copy data from 2 cells and paste it on sheet2 and clear the textboxes from Sheet1 Link https://docs.google.com/spreadsheets/d/1RiLjepEpYhkhCTgMHxrTxSI7GWloj954C4dsq0jT11E/edit?usp=sharing

CodePudding user response:

Description

To monitor if a checkbox has been clicked, (not true or false) you can use an onEdit(e) simple trigger. When the checkbox is clicked it will momentarily display a check and then the onEdit() clears both the dropdown selections and the checkbox.

I think I have given you enough to get started. I hope you will use the references to research other aspects of Google Spreadsheet and javascript.

Script

function onEdit(e) {
  try {
    if( e.range.getSheet().getName() === "Sheet1" ) {
      if( e.range.getA1Notation() === "D5" ) {
        let range = e.range.getSheet().getRange("C5:C8")
        let values = range.getValues();
        let picks = values.filter( row => row[0] !== "" ).flat();
        let results = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet2");
        results.appendRow(picks);
        values.forEach( row => row[0] = "" );
        range.setValues(values);
        e.range.setValue(false);
      }
    }
  }
  catch(err) {
    SpreadsheetApp.getUi().alert(err);
  }
}

Reference

  • Related