this is my first post, so forgive me if the question is not worded quite the way it is for the platform.
I'm currently working on a Google Apps script that is supposed to search a sheet (name: "[Overview] All Cases") and its rows for a certain value in column Y. This particular value is "No". If a row has this value, this row should be copied to the last row of another sheet ("OPS_FUNNEL").The row should then exist in both sheets. Can anyone help?
I have been through countless threads and have not been able to gather a solution. My solution so far, which does not work, you can see here:
function copy_to_OPS_FUNNEL() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var srcSheet = ss.getSheetByName("[Overview] All_Cases");
var tarSheet = ss.getSheetByName("OPS_FUNNEL_new");
var lastRow = srcSheet.getLastRow();
for (var i = 2; i <= lastRow; i++) {
var cell = srcSheet.getRange("Y" + i);
var val = cell.getValue();
if (val == 'No') {
var srcRange = srcSheet.getRange("A" + i + ":B" + i);
var sourcevalues = srcRange.getValues();
var tarRow = tarSheet.getLastRow();
var tarRange = tarSheet.getRange("A" + (tarRow + i) + ":B" + (tarRow + i));
tarRange.setValues(sourcevalues);
srcSheet.getRange("Y"+(i+0).toString()).setValue("Yes");
}
else{
}
}
}