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

Upgrade php version of xampp not success -

amazon web services - S3 and apache mod_proxy with basic authentication -

powershell - This solution contains one or more assemblies targeted for the global assembly cache -