Reputation: 43
I am trying to change the values of a range of code in my spreadsheet, to reset a template back to default values when done. I found this code as an example on another thread, but can't ask there because you can't ask questions or something.
function storeValue() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
// ss is now the spreadsheet the script is associated with
var sheet = ss.getSheets()[0];
var values = [
["2.000", "1,000,000", "$2.99"]
];
var range = sheet.getRange("B2:D2");
range.setValues(values);
}
This works great, changes those three cells to the value needed. This isn't what I ultimately need, but it works. I want to change the values in A8-A10 though, and when I change that cell range(And nothing else),I get the following error: Incorrect range height, was 1 but should be 3
What am I doing wrong here? I'm sure it's simple.
Upvotes: 1
Views: 3534
Reputation: 10259
The values array you have will write to columns in a row. To write to row in a column change to:
var values = [["2.000"], ["1,000,000"], ["$2.99"]];
Upvotes: 3