Hi,
I need to create a backup of the row values in the even a certain column's text contains "Yes". I am using a script which copies the row data but there are two issues:
1. Copies formulas instead of values (copyValuesToRange doesn't seem to be working)
2. The column with "Yes" is autofilled based on other cells, so the onEdit script doesn't seem to consider this as an edit. If i manually enter "Yes" in the column, the row is copied, but it isn't copied if the column value is auto filled with Yes.
The script I am using is this :
function onEdit(event) {
// source data in sheet named Master Data
// target sheet of move to named Backup
// test column with yes/no is col 27 or AA
var ss = SpreadsheetApp.getActiveSpreadsheet();
var s = event.source.getActiveSheet();
var r = event.source.getActiveRange();
if(s.getName() == "Master Data" && r.getColumn() == 27 && r.getValue() == "Yes") {
var row = r.getRow();
var numColumns = s.getLastColumn();
var targetSheet = ss.getSheetByName("Backup");
var target = targetSheet.getRange(targetSheet.getLastRow() + 1, 1);
s.getRange(row, 1, 1, numColumns).copyTo(target);
}
}