0

I'm using the following script in a google sheet that i copied it should add up all the amount in the column 15 starting from row 3, but it doesn't look at all at negative numbers it just skips it. i'm new at this scripting and i only adjusted the get range.

Should i somehow adjust the following line if (parseFloat(values[i]) > 0)

I tried "!=" but that gives "#NUM!" changeing 0 into -100000 works but that is a work around

I would be very greatfull if someone could help me out.

function onOpen() {
  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  var performanceSheet = spreadsheet.getSheetByName('Performance');
  var rng = performanceSheet.getRange(3,15,performanceSheet.getLastRow());
  var values = rng.getValues()
  var total = 0
  for (var i = 0; i < values.length; i++) {
    if (parseFloat(values[i]) > 0) {
      total = total + parseFloat(values[i]);
4

1 回答 1

1

删除这个:

if (parseFloat(values[i]) > 0) {

和另一个:

}
于 2020-06-07T14:47:02.397 回答