I am trying to input timestamps into a dashboard like layout and need the script to only insert timestamps in a specific range
i have this code from Here
* Creates a Date Stamp if a column is edited.
*/
//CORE VARIABLES
// The column you want to check if something is entered.
var COLUMNTOCHECK = 4;
// Where you want the date time stamp offset from the input location. [row, column]
var DATETIMELOCATION = [0,1];
// Sheet you are working on
var SHEETNAME = 'Cover Page'
function onEdit(e) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
//checks that we're on the correct sheet.
if( sheet.getSheetName() == SHEETNAME ) {
var selectedCell = ss.getActiveCell();
//checks the column to ensure it is on the one we want to cause the date to appear.
if( selectedCell.getColumn() == COLUMNTOCHECK) {
var dateTimeCell = selectedCell.offset(DATETIMELOCATION[0],DATETIMELOCATION[1]);
dateTimeCell.setValue(new Date());
}
}
}
i need it only to apply to E12:E19
Any help would be wonderful
Replace the script you have with
function onEdit(e) {
var sheet = e.source.getActiveSheet();
if (sheet.getName() == 'Cover Page' && e.range.columnStart === 5 && e.range.rowStart > 11 && e.range.rowStart < 20) {
e.range.offset(0, 1).setValue(new Date());
}
}
and see if that works?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.