Sunday, May 19, 2024
37
rated 0 times [  38] [ 1]  / answers: 1 / hits: 48823  / 10 Years ago, wed, april 2, 2014, 12:00:00

I'm currently working on a script that will import the holiday and appointments calender to make it public, however there are some things on this holiday calendar that need removing so after the sheets are imported i'm scanning the values of each cell to remove the cells that contain stuff others shouldnt be able to see



var code = ss.getSheetByName(mysheet).getRange(k,j).getValue();
if (code != HD || code != H || code != BH || code !== ) {
ss.getSheetByName(mysheet).getRange(k,j).setValue();
}


This is the code that is used for getting the value of the cell and checking it, it looks for cells that are not blank or do not contain any off the allowed codes however for some reason it keeps picking up every blank cell, why is this?



Also is there any over way to make this code run more faster and effectively?



function scanSheet(mysheet,lastdatecol){
var lastrw= ss.getSheetByName(mysheet).getDataRange().getLastRow();
for (var k=3; k<=lastrw; k++){
var surname = holidayNamesObjects[k-3].surname;
var forename = holidayNamesObjects[k-3].firstName;
ss.getSheetByName(mysheet).getRange(k, 1).setValue(forename + + surname)
for (var j = 3; j < lastdatecol+1; j++){
var code = ss.getSheetByName(mysheet).getRange(k,j).getValue();
if (code != HD || code != H || code != BH || code !== ) {
ss.getSheetByName(mysheet).getRange(k,j).setValue();
}
}
}
}

More From » google-apps-script

 Answers
2

code !== needs to be code !=
Using && code instead may work better


[#71663] Tuesday, April 1, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
raveno

Total Points: 453
Total Questions: 92
Total Answers: 92

Location: France
Member since Thu, Oct 27, 2022
2 Years ago
raveno questions
;