I am making a script for the google spreadsheet that goes through the rows and columns in search of specific values ​​and counts them for me, to later write it in another sheet.
This is the script I have right now:
function myFunction() {
var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Calvià ");
var lastrow = ss.getLastRow();
var nombres = 2;
var parque = 2;
var posiciong = 2;
var posiciongr = 2;
for (r=7; r<lastrow+1; r++){
var G = 0;
var GR = 0;
var range = ss.getRange(r,1).getValue();
if (range!=0){
var range2 = ss.getRange(r,4).getValue();
SpreadsheetApp.getActiveSpreadsheet().getSheetByName("ContadorHoras").getRange(nombres, 1).setValue(range);
SpreadsheetApp.getActiveSpreadsheet().getSheetByName("ContadorHoras").getRange(parque, 2).setValue(range2);
nombres = nombres + 1;
parque = parque +1;
for (c=6; c<93; c++){
var rangec = ss.getRange(r,c).getValue().toString;
if (rangec="G"){
G = G + 1;
}if (rangec="GR"){
GR = GR + 1;
}
}
SpreadsheetApp.getActiveSpreadsheet().getSheetByName("ContadorHoras").getRange(posiciong, 3).setValue(G);
SpreadsheetApp.getActiveSpreadsheet().getSheetByName("ContadorHoras").getRange(posiciongr, 4).setValue(GR);
posiciong = posiciong + 1;
posiciongr = posiciongr + 1;
}
}
}
Everything works fine until I add the second for, with the first for, I go through the rows and with the second, the columns of each row looking for some values ​​and counting them, my problem is that I can't get this second for to work well, everything the time tells me that GY GR is 87.
The problem is that you are using the assignment operator
=
instead of one of the equality comparison operators,==
or===
.In other words, change
by
the same for the other equality comparisons
Related