I want to increment the value in the A1
cell.
function increment(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var cell = sheet.getRange("A1");
cellValue = cell.getValue("A1");
cell.SetValue(cellValue + 1);
}
How can I do that?
You are calling getValue()
with an argument. This function does not take any arguments, as can be seen in the documentation:
https://developers.google.com/apps-script/reference/spreadsheet/range#getValue()
function increment(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var range = sheet.getRange("A1");
//Returns the value of the top-left cell in the sheet
var value = range.getValue();
range.setValue(value + 1);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With