Reputation: 11
Sorry I am very new in coding and appreciate if you give me some advice on my coding.
My intention for the coding is if the google sheet able to find "TOR": in column D & date in column I, if both values are in the list then help me to change the value of F but if the values are not in the list then help me to record at another page.
I encounter some issues which are if the values are in column D and I, then everything ok, but if the values don't exist in the list then it cannot run another step, I can't found what the reason.
Appreciate if someone can help me to check the coding and give me some advice.
function CheckTOR(){
var ss = SpreadsheetApp.openByUrl(url);
var ws = ss.getSheetByName("RSS Route Plan");
var lastRow = ws.getLastRow();
var range = ws.getRange(1,2,lastRow,9);
var values = range.getValues();
for(var i =1; i < values.length; i++) {
if(values[i][2] == "TOR"
&& values[i][7] == "30/06/20"){
var rownumber = i;
if(rownumber > -1){
var CallRecord = ws.getRange(rownumber + 1, 8).getValue();
ws.getRange(rownumber + 1,8,1,1).setValue(CallRecord + 1);
} else {
var ws1 = ss.getSheetByName("Sheet16");
ws1.getRange(1,1).setValue(1);
}
}
}
Upvotes: 0
Views: 57
Reputation: 11
The answer based on advice from TheMaster,
function CheckTOR(CRO,date){
var ss = SpreadsheetApp.openByUrl(url);
var ws = ss.getSheetByName("RSS Route Plan");
var lastRow = ws.getLastRow();
var range = ws.getRange(1,2,lastRow,9);
var values = range.getValues();
for(var i =1; i < values.length; i++) {
if(values[i][2] == "TOR" && values[i][7] == "10/06/20" && i > -1) {
var CallRecord = ws.getRange(i + 1, 8).getValue();
ws.getRange(i + 1,8,1,1).setValue(CallRecord + 1);
}
}
}
Upvotes: 1