I have decided to use Google Scripts when I can when using spreadsheets, just to start increasing knowledge. BUT I am untrained and got stuck quite quickly.
I saw some code on youtube for a different script but I thought I extracted what I needed and could get this to work...
function y_add_up_function() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var range = sheet.getRange["I2:J15"];
var data = range.getValues();
var sum = 0;
for (var i = 0; i < 14; ++i)
{
var row = data[i];
if(row[1] == "y")
{
sum = sum + row[0];
}
}
return sum;
}
This is my spreadsheet. I am trying to just simply get the SS to add up where I have ticked y
next to a price, but I am getting an error that reads:
TypeError: Cannot call method "getValues" of undefined. (Line 5)
Please teach me what I am doing wrong ^_^!!!
Cheers!