How do I make the onEdit function work independently on different sheets? You will see I made this script that works perfectly on the active sheet (Col Y). I have 8 sheets (different names) in which when modifying a specific column I stamp the date and time in the adjacent cell, for each sheet it is a different column. Try to do several functions onedit and none of them work. Thank you for your support.
function onEdit(event){
var ColY = 25; // Número de la Columna "Y"
var changedRange = event.source.getActiveRange();
if (changedRange.getColumn() == ColY) {
// Una celda de la Columna Y ha sido editada
var state = changedRange.getValue();
var adjacent = event.source.getActiveSheet().getRange(changedRange.getRow(),ColY+1);
var timestamp = new Date(); // Obtener la fecha actual
// Dependiendo del valor de la celda será lo que se hará
switch (state) {
case 'Liquidado':
// Escribir la fecha en la celda contigua
adjacent.setValue(timestamp);
break;
case 'En Stock':
adjacent.setValue(timestamp);
break;
default:
// Algo que no se esperaba
adjacent.setValue("*ERROR*");
break
}
}
}