Here is my test sheet that I am using to try and get this to work: https://docs.google.com/spreadsheets/d/1-KjA7AdLxh6xTLyx3FTP_XuXZlm6vZ0IlrLMO2TTLOE/edit#gid=1008104959
I currently have a working script that will auto update a time stamp in D1 when info in cell B3 is edited. What I would like it to do is the same thing but also function when I paste info(a large data set) that would go onto B3 and down.
this is the script I currently have working, and I just need it to work when info is pasted in B3, not just when it is manually edited:
/**
* Simple trigger that runs each time the user edits a cell in the spreadsheet.
*
* @param {Object} e The onOpen() event object.
*/
function onEdit(e) {
if (!e) {
throw new Error('Please do not run the script in the script editor window. It runs automatically when you edit the spreadsheet.');
}
if (e.range.getB3Notation() !== 'B3') {
return;
}
var message = 'Hello world! Cell B3 was changed ';
message += 'from "' + e.oldValue + '" ';
message += 'to "' + e.value + '".';
var spreadsheet = SpreadsheetApp.getActive();
spreadsheet.getRange('D1').activate();
spreadsheet.getActiveRangeList().setValue(new Date());
}
Try this:
function onEdit(e) {
const sh = e.range.getSheet();
if (e.range.columnStart == 2 && e.range.rowStart == 3 && !e.value) {
sh.getRange("D1").setValue(new Date());
}
}
This only capture paste where range starts in B3 and proceeds below
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.