'Deleting row in one sheet if cell value is found in another sheet
I am trying to delete rows if cell value is found in another sheet via App Script. But the code is not going through complete data in history sheet.
function deleteOld1() {
var app = SpreadsheetApp;
var orderSheet = app.getActiveSpreadsheet().getSheetByName("RC"); \sheet where to look
var historySheet = app.getActiveSpreadsheet().getSheetByName("OB"); \sheet from which data has to be deleted
var lastRow = historySheet.getLastRow();
var lastRow1 = orderSheet.getLastRow();
var poNO = orderSheet.getRange("A2:A" + lastRow);
var myRange = historySheet.getRange("A2:A" + lastRow1);
var row = poNO.getRow();
var col = poNO.getColumn();
var data = myRange.getValues();
var data1 = poNO.getValues();
if (col>= poNO.getColumn() && col <= poNO.getColumn() && row>= poNO.getRow() && row <= poNO.getRow()){
for (i=0; i<data.length; i++) {
for (j=0; j<data1.length; j++){
if(data[i][0] == data1[j][0]){
historySheet.deleteRow(i+2);
}
}
}
}
}
Please go through this code and help
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
