The onEdit(e) function in Google Sheets Script Editor only captures edits on single cells. Is there a way to make it capture edits on multiple cells, for example, if I copy information into 20 cells, can onEdit(e) recognise that 20 cells have been edited rather than just the first cell?
I've looked everywhere for a solution to this and I can't find any instance of someone asking this question.
function recordChange(c){
var range = c.range;
var column = 8; //Column for change log
var row = range.getRow();
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var oldRow = range.getRow();
var oldColumn = range.getColumn();
sheet.getRange(oldRow, oldColumn).setBackground("orange");
var changeCell = sheet.getRange(row, column)
changeCell.setValue(new Date())
var testCell = sheet.getRange(2, 2)
var test = range.getValues();
var newT = test.map(function(x){ return x});
testCell.setValue(newT)
}
function recordAction(c){
var range = c.range;
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var row = range.getRow();
for (var i = 1; i<9; i++){
sheet.getRange(row, i).setBackground(null);
}
}
//Main Function
function onEdit(e){
var range = e.range;
if (range.getRow() != 1){
if (range.getColumn() != 9 && range.getColumn() != 8) {recordChange(e);} else {recordAction(e);}
}
}
Editing a cell should add the date in a separate column and highlight the cell in orange. This works, however when I try editing multiple cells it just registers the first one, so it is pretty useless as a means to record edits on a sheet.
I'm assuming there was a way of capturing multiple edits in an array, however I can't find any obvious way of doing this.