Adding a value to a cell in javascript -


i have created function increase cell value 1. goal make value of am39 increase 1, not go past 2. have fixed syntax errors, i've tried running script script hasn't done anything.

what wrong function?

function incrementcellvaluesbyone() {  var ss = spreadsheetapp.getactivespreadsheet(); var sheet = ss.getsheets()[0]; var cell = sheet.getrange("am39"); var cell, cellvalue;  if (cellvalue == cell.getvalue()) {     cell.setvalue(cellvalue + 1);      if (cellvalue >= 2) {         cellvalue = 2;     } } } 

edit:

range.setvalue(value + 1);  if (cellvalue >= 2) {     cellvalue = 2; } 

you have wrong in define , ordering of statements! try this:

function incrementcellvaluesbyone() {     var ss = spreadsheetapp.getactivespreadsheet();     var sheet = ss.getsheets()[0];     var cell, cellvalue;     cellvalue = "something should make here!";     cell = sheet.getrange("am39");      if (cellvalue == cell.getvalue()) {         cell.setvalue(cellvalue + 1);         if (cellvalue >= 2) {             cellvalue = 2;         }     } } 

Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -