Wpis z mikrobloga

Pomocy z #googlesheets / #excel i #javascript . Mam dwa arkusze i dwie funkcje które są praktycznie takie same. Czemu działa mi tylko jedna onEdit, a nie wyrzuca żadnych błędów, ani jedna ani druga.
Są dwa arkusze Main i Data w jednym pliku google sheet.

var s = SpreadsheetApp.getActiveSheet();
var r = s.getActiveCell();

function onInput() {
if( s.getName() == "Main" ) { //checks that we're on Sheet1 or not
if( r.getColumn() == 1 ) { //checks that the cell being edited is in column A
var nextCell = r.offset(0, 1);
if( nextCell.getValue() === '' ) //checks if the adjacent cell is empty or not?
nextCell.setValue(new Date());
}
}
}

function onEdit() {
if( s.getName() == "Data" ) { //checks that we're on Sheet1 or not
if( r.getColumn() == 1 ) { //checks that the cell being edited is in column A
var nextCell = r.offset(0, 1);
if( nextCell.getValue() === '' ) //checks if the adjacent cell is empty or not?
nextCell.setValue(new Date());
}
}
}

#programowanie
  • 2
  • Odpowiedz
  • Otrzymuj powiadomienia
    o nowych komentarzach

Czemu działa mi tylko jedna onEdit, a nie wyrzuca żadnych błędów, ani jedna ani druga.


@ortaliontrenera: to zależy co rozumiesz pod pojęciem "działa". Działają obie, tylko onEdit wywoływana jest przy edycji komórki, a jak wywołujesz onInput?
  • Odpowiedz