Advertisement
Namokonov

log_select_sheets_ranges

Sep 7th, 2021
1,480
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let dict =
  2. {
  3.   'Лист1': { colFrom: 1, colTo: 5, rowFrom: 1, rowTo: 5 },
  4.   'Лист2': { colFrom: 1, colTo: 5, rowFrom: 1, rowTo: 5 }
  5. };
  6.  
  7.  
  8. function onEdit(e) {
  9.   let [shName, row, col] = [e.source.getSheetName(), e.range.getRow(), e.range.getColumn()]
  10.  
  11.   if (e.value != e.oldValue
  12.     && shName in dict
  13.     && dict[shName].colFrom <= col && dict[shName].colTo >= col
  14.     && dict[shName].rowFrom <= row && dict[shName].rowTo >= row
  15.   ) {
  16.     let ss = e.source;
  17.     let sh = ss.getSheetByName('лог') || ss.insertSheet('лог');
  18.     let email = Session.getEffectiveUser().getEmail();
  19.     let log_data = [e.source.getSheetName(), e.range.getA1Notation(), e.value, e.oldValue, email, new Date()];
  20.     sh.appendRow(log_data);
  21.   }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement