Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // working timestamp code
- // function onEdit(e) {
- // var ss = e.source;
- // var timestamps_sheet = ss.getSheetByName('timestamp_reference');
- // const row = e.range.getRow();
- // if (row > 1) {
- // if (e.source.getActiveSheet().getName() === "sports_team") {
- // const currentDate = new Date();
- // timestamps_sheet.getRange(row, 1).setValue(currentDate);
- // }
- // }
- // }
- // working code to find row # where cell = "timestamp"
- // function onEdit(e){
- // var ss = SpreadsheetApp.getActiveSpreadsheet();
- // var thisSheet = ss.getActiveSheet();
- // var tf = thisSheet.createTextFinder("timestamp");
- // var thisRow = tf.findNext().getRow();
- // // var thisCol = tf.findNext().getColumn();
- // Browser.msgBox(thisRow, Browser.Buttons.OK_CANCEL);
- // return thisRow;
- // }
- // working code to find column # ONLY if "timestamp" is in Row 1. Unable to figure how to find column # after Row 1
- // function onEdit(e) {
- // var headers = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('sports_team').getDataRange().getValues().shift();
- // var colindex = headers.indexOf("timestamp");
- // Browser.msgBox(colindex+1, Browser.Buttons.OK_CANCEL);
- // // return colindex+1;
- // }
- function onEdit(e){
- var ss = SpreadsheetApp.getActiveSpreadsheet();
- var thisSheet = ss.getActiveSheet();
- var tf = thisSheet.createTextFinder("timestamp");
- // This finds Row # where cell = "timestamp"
- var thisRow = tf.findNext().getRow();
- // This is supposed to find Col # where it = "timestamp" but I'm having issues
- var thisCol = tf.findNext().getColumn();
- var ss = e.source;
- var main_sheet = ss.getSheetByName('sports_team');
- const row = e.range.getRow();
- if (e.source.getActiveSheet().getName() === "sports_team") {
- const currentDate = new Date();
- main_sheet.getRange(thisRow, thisCol).setValue(currentDate);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement