I'm trying to create a custom Function in Google Spreadsheets that takes a range as input parameter.
function Example(cells){
var values = SpreadsheetApp.getActiveSpreadsheet().getRange(cells).getValues();
var sum = 0;
for(var i=0;i<values.length;i++){
sum += values[i][0];
}
return [sum];
}
When I try to call Example, I can't use something like Example(C15:D20)
instead I need to pass the range as string like Example("C15:D20")
.
The only problem passing range in string format is that cells are not updated when any of the values in range is updated.
Is there any work around for this?