Advertisement
RemcoE33

Copy name to U

Jun 21st, 2021
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function onEdit(e) {
  2.   const sheetName = 'Data';
  3.   const startRow = 5;
  4.   const startColumn = 2;
  5.   const endRow = 28;
  6.   const endColumn = 20;
  7.   const currentRow = e.range.getRow();
  8.   const currentColumn = e.range.getColumn()
  9.   if (e.source.getActiveSheet().getName() == sheetName && typeof e.value == 'string'){
  10.     console.log('Sheet true')
  11.     if (currentRow >= startRow && currentRow <= endRow && currentColumn >= startColumn && currentColumn <= endColumn) {
  12.       console.log('inside range')
  13.       const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName)
  14.       const columnUlastRow = sheet.getRange("U1").getNextDataCell(SpreadsheetApp.Direction.DOWN).getRow()
  15.       sheet.getRange(columnUlastRow+1,21).setValue(e.value)
  16.     }
  17.   }
  18. }
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement