I'm doing a loop in google sheets script, i'm trying to find a row in the "Inventar" sheet that has the same value found in the sheet "Fisa client" and then change the value of a cell in that row but it appears that it does not enter the second for. I'm new to this so i don't know what's the problem.
function adaugabucati1(){
var sheet = SpreadsheetApp.getActiveSpreadsheet();
var ss=sheet.getSheetByName('Fisa client');
var ss2=sheet.getSheetByName('Inventar');
var data = ss.getRange("g9:l18").getValues();
var data1=ss2.getDataRange().getValue();
for(var i=0;i<data.length;i++){
if(!data[i][0] == ""){
var cod = ss.getRange(i+9,8).getValue();
var buc = ss.getRange(i+9,10).getValue();
for(var y=0;y<data1.length;y++){
if(data1[y][5] == cod){
var bucati = data[y][7]-buc;
ss2.getRange(y+1,8).setValue(bucati);
}
}
}
}
}