Fix 20-line Google script for Google Sheets

Job ID: 32695633

Budget: $30 – $250 USD

The 20-line Google script below is to remove all rows in Sheet1 one that in any column substring-match any value inside column A on Sheet2. It's not working correctly. When you run the script once, the row with the value "ccc" in Sheet1 is still there even though it "c" is one of the values inside column A in Sheet2. I'm looking for a fix to the script. I have $50 for this if you can turn this around in one hour.

Below is a link to a public sheet you can copy.

Thanks.

https://docs.google.com/spreadsheets/d/1_BAoHzV2v9BIiaPdbjKhd8JD_ChsJzfpo1lsgYRPBMA/edit#gid=0

Script:

function onOpen() {
const ui = SpreadsheetApp.getUi();
ui.createMenu('Functions')
.addItem('Unsubscribe', 'est_unsubscribe')
.addToUi();
}

function est_unsubscribe() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var unsubscribe=ss.getSheetByName("Sheet2");
var sheet = ss.getActiveSheet();
var dataRange = sheet.getDataRange();
var values = dataRange.getValues();
var lastrow=unsubscribe.getLastRow();
var findvalue="";
for(var k=1;k<=lastrow;k++){
findvalue=unsubscribe.getRange(k,1).getValue().toString();
console.log(findvalue);
for (var i = 0; i < values.length; i++) {
var row = "";
for (var j = 0; j < values[i].length; j++) {

if (values[i][j].toString().includes(findvalue)) {
row = values[i][j+1];
var increment=i;
sheet.deleteRow(++increment) // This is your row number
}
}
}
}
}
Related categories: Google Sheets Google Apps Scripts