How to get the whole range of the onEdit(e) by Google Sheets script? I have tried the following script:
var sheet = spreadsheet.getActiveSheet();
function onEdit(e){
var row = e.range.getRow();
var column = e.range.getColumn();
sheet.getRange('A1').setNote(range.getRow() + ',' + range.getColumn());
}
Well, it works if I edit only one cell. For example, if I edit cell B2, then it will set the note of cell A1 to be "2,2". But what if I edit multiple cells simultaneously? For example, suppose the values of range(‘A2:B3’) are all non-empty (say, all ‘abc’) and I copy range(‘A2:B3’) and paste it to range(‘A10:B11’). Then, the note of cell A1 will only show "10,1" (i.e., row and column of cell A10). How can I show the WHOLE RANGE (instead of merely the top left cell), for example, "10,1,2,2" or the rows and columns of ‘A10’ and ‘B11’? Thank you!
2
Answers
You can use these variables to get the whole edited range
This will put a note in every cell you edit as long as the range is contiguous.