Advertisement
Guest User

DateStamp1203

a guest
May 22nd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. /**
  2. * Creates a Date Stamp if a column is edited.
  3. */
  4.  
  5. //CORE VARIABLES
  6. // The column you want to check if something is entered.
  7. var COLUMNTOCHECK = 2;
  8. // Where you want the date time stamp offset from the input location. [row, column]
  9. var DATETIMELOCATION = [0,-1];
  10. // Sheet you are working on
  11. var SHEETNAME = 'Sheet1'
  12.  
  13. function onEdit(e) {
  14. var ss = SpreadsheetApp.getActiveSpreadsheet();
  15. var sheet = ss.getActiveSheet();
  16. //checks that we're on the correct sheet.
  17. if( sheet.getSheetName() == SHEETNAME ) {
  18. var selectedCell = ss.getActiveCell();
  19. //checks the column to ensure it is on the one we want to cause the date to appear.
  20. if( selectedCell.getColumn() == COLUMNTOCHECK) {
  21. var dateTimeCell = selectedCell.offset(DATETIMELOCATION[0],DATETIMELOCATION[1]);
  22. dateTimeCell.setValue(new Date());
  23. }
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement