code to explanationWed, 18 Jan 2023

function onEdit(e) { var sheet = e.source.getActiveSheet(); if (sheet.getName() == 'Sheet1' && e.range.getColumn() == 16) { var selection = e.range.getValue(); if (selection !== '') { var cellToChange = sheet.getRange(e.range.getRow(), e.range.getColumn() - 1); if (cellToChange.getValue() !== "cadastrada") { cellToChange.setValue('peticionar'); } } } }

This function is executed when a user makes a modification in a cell in the sheet Sheet1. The function gets the current sheet and checks if the columns is 16. If it is, it checks if the value of the cell is different from an empty string. If it isn't, it gets the sheet, the row and the column of the cell, and checks if the value of the cell is different from cadastrada. If it is, it sets the cell value to peticionar.

Questions about programming?Chat with your personal AI assistant