I am attempting to do a very simple function but I am having issues getting it to work as intended.
My goal is to read the value out of column 2 and if it is "Yes", add it to a variable named total. I want that total to be returned to the location I specify the function in.
So far, I can only get a number 2 to return back to the sheet. What am I doing wrong?
Below is my code so far:
function confirmationTotal() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var i = 2
var total = 0
while (true) {
var column1Box = ss.getRange("B" + i);
var column2Box = ss.getRange("C" + i);
var value = column2Box.getValue();
if(value == "Yes") {
total = total + column1Box.getValue()
i = i + 1
}
if(value == "Pending") {
i = i + 1
}
else
break;
}
return total
}