Google Apps Script: Update Column When Row Is Modified/Edited

At Google Sheets, click Tools -> Script Editor.

The following code will update Column J to 1 when row is edited/modified.

function onEdit(e) {  var range = e.range;  var sheet = range.getSheet();  var updateCol = "J";  var updateCoIndex = updateCol.charCodeAt(0) - 64  /*  // limit to specific sheet  // sheet.getSheetId()  if (sheet.getName() !== sheetName) {    return;  }   */  if (range.getColumn() != updateColIndex) {    var row = range.getRow()    // Update Column J to 1 when row is edited    var updateRange = sheet.getRange(updateCol + row.toString());    updateRange.setValue(1);    // range.setNote('Last modified: ' + new Date());  }}

References:

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.