Reputation: 3
Not sure how to go about incrementing the number values on my google spreadsheet by 1 with a button, the script I'm using only increments the first cell and copies that down. How can I make the script increment the whole column and it's individual cells by 1?
function increment(){
var cell = SpreadsheetApp.getActiveSheet().getRange("C2:C86");
var cellValue = cell.getValue();
cell.setValue(cellValue + 1);
}
Upvotes: 0
Views: 2153
Reputation: 201573
If my understanding is correct, how about this modification? Please think of this as just one of several answers.
function increment(){
var cell = SpreadsheetApp.getActiveSheet().getRange("C2:C86");
var cellValues = cell.getValues().map(function(row) {return [row[0] + 1]}); // Modified
cell.setValues(cellValues); // Modified
}
If I misunderstood your question and this was not the result you want, I apologize.
Upvotes: 1