简体   繁体   中英

Date Stamp for Google Sheets Script

Need some help with this script. Only one of the desired date stamps is working. Right now data entry in column 19 prompts a date stamp in column 20, however nothing happens in column 14 when data is entered in column 13.

function onEdit(e) {
    var sh = e.source.getActiveSheet()
    var colToWatch = 13 
    var colToStamp = 14
    var colToWatch = 19 
    var colToStamp = 20

    if (sh.getName() !== 'Pending Orders'
        || e.range.columnStart != colToWatch
        || e.range.rowStart < 4)  {
            return;
    }

    sh.getRange(e.range.rowStart, colToStamp)
        .setValue(new Date())
}

Thank you

The code is overwriting the previously assigned values (there two lines var colToWatch and two var colToStamp )

You should use different variables names on each var code lines and to change if condition accordingly.

Related

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM