Add earnings from the same employee

0

I'm trying to add up all the earnings of an official (cumulative sum), but I can not. The code is below:

function teto() {    
  var ss = SpreadsheetApp; //seta a planilha 
  var planilhaAtiva = ss.getActiveSpreadsheet(); //torna-a ativa
  var abaAtiva = planilhaAtiva.getActiveSheet(); //seta a aba ativa

  for (var i = 2; i < 10; i++) {
    var cpf = [i][3];
    var valor = [i][11];

    if (cpf = cpf+1) {
      valor = valor + (valor + 1);
      abaAtiva.getRange(i,13).setValue(valor); 

    }
  }
}

Explaining: I have a column with cpfs grouped from multiple employees, and another column with the commission amount it receives. If the cpf of a line is equal to the cpf of the bottom line, it does the sum . It should do this sum while the CPFs are equal, and put this value in a new column - C, SOMA. If it is not the same, I do not want it to go back to the previous one, but start a new sum with the new set of values from the same cpf.

    
asked by anonymous 15.07.2018 / 22:37

0 answers