function onEdit(e){
const row = e.range.getRow();
const col = e.range.getColumn();
const sheetName = "Week1";
if (col === 4 && row > 3 && e.source.getActiveSheet().getName() === "Week1"){
var activeSpreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var targetSpreadsheetId = "TargetSpreadsheetID";
var targetSpreadsheet = SpreadsheetApp.openById(targetSpreadsheetId);
var targetSheet = targetSpreadsheet.getSheetByName("Week#1");
var targetRow = range.getRow();
var timestamp = new Date();
var formattedTimestamp = Utilities.formatDate(timestamp, Session.getScriptTimeZone(), "yyyy-MM-dd HH:mm:ss");
targetSheet.getRange(row,2).setValue(formattedTimestamp);
if(targetSheet.getRange(row,1).getValue() == ""){
targetSheet.getRange(row,1).setValue(formattedTimestamp);
}
}
}
0 comments:
Post a Comment
Thanks