I have made function that will insert new row and copy to the first and second column some data from another sheet. If there is N/A error in P and Q column together I want my function to copy data from column A and B on the same row. It's actually work, add row and stuff but it copying all data even if there is not N/A error row by row
var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("MainShops");
var ssd = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("ShopsData");
function AddShops() {
for(j=2; j < 278; j++) {
var DoubleRowCheck = ssd.getRange(j, 16, 1, 2).getValues();
if (DoubleRowCheck == "#N/A", "#N/A") {
var ShopsToAdd = ssd.getRange(j, 1, 1, 2).getValues();
var LastRow = ss.getLastRow();
var LastRowPlusOne = LastRow + 1;
ss.insertRowAfter(LastRow);
ss.getRange(LastRowPlusOne, 1, 1, 2).setValues(ShopsToAdd);
}
else {
continue;
}
}
}