Hope you are doing well!
I want to make the function I created, 'webScraping11,' run onEdit when columns AG, AS, or AU are modified but only in a specific row. For example, when we modify row 11, column AG, the functions should be executed, but only in that row (11).
I tried but without luck:
function onEdit(e) {
var hojaActual = e.source.getSheetByName("Duplicado");
if (hojaActual && hojaActual.getName() === "Duplicado") {
var celdaActiva = e.range;
var filaActiva = celdaActiva.getRow();
var colActiva = celdaActiva.getColumn();
var valor = celdaActiva.getValue();
if (colActiva === 33 || colActiva === 45 || colActiva === 47) {
webScraping11(hojaActual, filaActiva);
}
}
}
The error is:
TypeError: Cannot read properties of undefined (reading 'source')
function onEdit(e) {
const sh = e.range.getSheet();
const idx = [33, 45, 47].indexOf(e.range.columnStart);
if (sh.getName() == "Duplicado" && ~idx) {
webScraping11(sh, e.range.rowStart);
}
}
Note this function requires an onEdit event object. You cannot run it from the script editor or call it unless you supply the event object