Home > Software design >  Google Script to Copy cells value to another Google sheet
Google Script to Copy cells value to another Google sheet

Time:03-26

I am having 2 google sheet, having checkbox on 1st Sheet. Requirement: When the checkbox is checked , Value from Cell C5 need to be stored in the Sheet2. When the checkbox is checked i.e value is 'True', the value in cell C5 of the Sheet1 needs to be submitted in the Sheet2 in the continuous manner. I know this is the silly requirement, but I failed after several attempts as well.

CodePudding user response:

Try

function onEdit(event) {
  var sh1 = event.source.getActiveSheet();
  var r = event.source.getActiveRange();
  if (sh1.getName() == 'Sheet1' && r.getA1Notation() == 'D5' && r.getValue() == true) {
    var sh2 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Sheet2')
    sh2.getRange('A'   (sh2.getLastRow()   1)).setValue(r.offset(0, -1).getValue())
    r.setValue(!r.getValue())
  }
}
  • Related