I would like to copy entire row(s) into another sheet if A(i) equals the content of a cell (see criteria).
Example:
My criteria (which is located in ws2.A4) = "good"
Copy row 7 into ws1.A5 as ws1.A7 = "good"
Copy row 8 into ws1.A6 as ws1.A8 = "good"
But not the other rows.
(Note: I am trying to adapt this vba code into GAS https://stackoverflow.com/a/12185026/457557)
Here is where I blocked now :
function copy_row_s_if_cellAi_equal_X() {
var ws1 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("base");
var ws2 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("ok");
var Alast = ws1.getLastRow()
var criteria = ws2.getRange(4 ,1).Value
var target = ws2.getRange(5 ,1)
for (var i = 3; i < Alast; i++ ) {
if (ws1.getRange(i ,1) == criteria) {
ws1.getRange(i ,1).copyTo(target, {contentsOnly:true}); // copy/paste content only
}
}
}