function ActualiserStock() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("DATA");
var lig=sheet.getRange("K1").getValue();
var sheet2 = ss.getSheetByName("STOCK");
var allProtections = sheet2.getActiveSheet().getProtections(SpreadsheetApp.ProtectionType.SHEET);
protection = allProtections[0];
protection.remove();
var range = sheet2.getRange("B2:C19");
range.clear({contentsOnly: true, skipFilteredRows: true});
for(lg=2; lg<20;lg++){
var cuve=sheet2.getRange(lg,1).getValue();
kit=0;
for (k = lig; kit == 0 && k >1; k--){
if (sheet.getRange(k,4).getValue() ==cuve){
var niv=sheet.getRange(k,7).getValue();
sheet2.getRange(lg,2).setValue(niv);
var nat=sheet.getRange(k,5).getValue();
sheet2.getRange(lg,3).setValue(nat);
kit=1;
};
};
};
var protection = sheet2.getActiveSheet().protect();
protection.setDescription('protege');
}