'How to update another sheet in App Script using openById() method
Here is my code can you help what did I do wrong with my code: the function texFinder(sheet = "ASC", findText = "abc12345"){...} works fine but it is not working when I call the fun.
function textFinder(sheet, findText) {
var sheetstolook = SpreadsheetApp.openById('1ifE_iXM9RJJBiHOQdpSlKnvGcnkvFk').getSheetByName(sheet).activate();
var SHTvalues = sheetstolook.createTextFinder(findText).findAll();
var result = SHTvalues.map(r => ({ row: r.getRow(), col: r.getColumn() }));
var toupdate = sheetstolook.getRange(result[0].row, result[0].col + 1).getValue();
sheetstolook.getRange(result[0].row, result[0].col + 1).setValue(toupdate - 1);
if (parseInt(toupdate) < 0) {
sheetstolook.getRange(result[0].row, result[0].col + 1).setBackgrounds('red');
}
}
function onEdit(e){
...
else if (col == 9 && e.source.getActiveSheet().getRange(row, 5).getValue().toUpperCase() === "FRM") {
var shsearch = e.source.getActiveSheet().getRange(row, 4).getValue().toUpperCase();
var shTxt = e.source.getActiveSheet().getRange(row, 9 ).getValue();
textFinder(shsearch, shTxt);
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
