Changing cell value based on another value on the same row on google submit form
I am very new to Google Forms and Spread Sheets and I want to have the Age question in my form and when the user submits the form I want it so that if the age is less than 18 the cell gets the MINOR value. and if it is 18 or higher, it is filled with "MAJOR".
Basically, I want to dynamically add a value to this cell base in the "AGE" value.
What I am doing right now:
function myfunction(e) {
var age = Number(e.values[3]);
var minmaj;
if (age < 18){
minmaj = "MINOR";
} else {
minmaj = "MAJOR";
}
SpreadsheetApp.getActiveSheet().getRange(e,14).setValue(minmaj);
}
Where e,14
is the cell of the minor / major value.
+3
source to share
2 answers
Yes, simple problem ...
SpreadsheetApp.getActiveSheet().getRange(e,14).setValue(minmaj);
^
On this line, you are trying to use an event variable e
as a line number. There should be something like this:
SpreadsheetApp.getActiveSheet().getRange(e.range.getRow(),14).setValue(minmaj);
^^^^^^^^^^^^^^^^
0
source to share