I have read these two links Google Script: Conditionally copy rows from one spreadsheet to another and https://stackoverflow.com/a/4809413/1526044 and after trying I am not able
I modified a similar script I answered recently that should do what you need. I didn't test but you can give it a try. There are some comments to explain the idea... it probably needs some debugging.
EDIT : I played around with this and debugged it a bit more ;-) so it seems to work as needed now - here is the link to my test sheet
function xxx(){
/* we have an array 'keysheet'
and an array datasheet , you get these with something like*/
var keysheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0].getDataRange().getValues();
// and
var datasheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[1].getDataRange().getValues();// if other columns, change index values in the arrays : 0=A, 1=B ...
// the iteration could be like this :
for(i=0;i