Scripts newbie here. I have a list of URLs in column A
I want tot create a button that helps me delete a row whenever the cell in column A contains one of a list of keywords. I was trying the code below to delete all rows where A contains "blogspot".
It is still not working. I get this error: "TypeError: thisVal.indexOf is not a function"
However, I'm not even sure I can add multiple strings in addition to "blogspot". For example, I would like to delete all rows containing blogspot, wordpress and wix.
function cleanRows() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sh = ss.getSheetByName('Master');
var colA_Vals = sh.getRange(1, 1, sh.getLastRow(), 1).getValues();
var i = 0,
j = 0,
thisVal,
chkVal,
arrayValsToChk = ['blogspot'];
for (i=colA_Vals.length;i>0;i-=1) {
thisVal = colA_Vals[i-1][0];
//Logger.log('i: ' + i);
for (j=0;j<arrayValsToChk.length;j+=1) {
chkVal = arrayValsToChk[j].toLowerCase() //Change to all lower case;
if (thisVal.indexOf(chkVal) !== -1) {
ss.deleteRow(i);
};
};
};
};