Hey I need some help with Google Sheets In sheet 1 "Inventory" I am trying to have the date auto populate in column 8 or I when data is entered in any cell in column 7 or G below row 3
this is what I have tried/as far as I have gotten
function onEdit(e) {
if (e.range.columnStart == 7 || e.range.rowStart < 4) return;
e.source.getActiveSheet().getRange(e.range.rowStart, 9)
.setValue(Utilities.formatDate(new Date(), "GMT", "dd/MM/yyyy"));
}
Thank you for any help!!
This should fix it:
function onEdit(e) {
if (e.range.columnStart == 7 || e.range.rowStart < 4){
e.source.getActiveSheet().getRange(e.range.rowStart, 9)
.setValue(Utilities.formatDate(new Date(), "GMT", "dd/MM/yyyy"));
}}
Ended up using this:
function onEdit() {
var s = SpreadsheetApp.getActiveSheet();
if( s.getName() == "Inventory" ) { //checks that we're on the correct sheet
var r = s.getActiveCell();
if( r.getColumn() == 7 ) { //checks the column
var nextCell = r.offset(0, +2);
if( nextCell.getValue() === '' ) //is empty?
nextCell.setNumberFormat("MMM dd/YY")
nextCell.setValue(new Date());
};
};
}
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.