I have seen before a google script that, in onEdit(e), automatically reversed whatever edit was made to a given sheet cell. I'd like some code for that!
Thanks for whatever help you can provide.
Your goal is to revert the current edit that was made. Namely, change the new value with the value that was before the edit was made.
In the following script choose the sheet name and the cell reference and after you edit that particular cell (A1 in Sheet1 in the example), the old value will be retrieved back to the cell.
function onEdit(e) {
const sheetName = "Sheet1"; // choose the name of the Sheet
const cell = "A1"; // choose the cell
const rng = e.range;
if(rng.getA1Notation() == cell && rng.getSheet().getName() == sheetName){
rng.setValue(e.oldValue);
}
}
Illustration:
Every edit on cell A1 is reversed.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.