0
votes

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

1

1 Answers

1
votes

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