Est-ce le résultat que tu attends ?
function Import_Coeff() {
var feuilleCALIB = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Calibration');
var lastRow = feuilleCALIB.getLastRow();
var tableau = feuilleCALIB.getRange('A3:B' + lastRow).getValues();
var result = [];
for (i = 0; i < tableau.length - 2; i++) {
if (tableau[i][0].substring(0, 2) == "50" || tableau[i][0].substring(0, 2) == "51" || tableau[i][0].substring(0, 2) == "52") {
if (tableau[i + 2].toString().indexOf('x', 0) != -1) {
var ATA = tableau[i][0].split("-")[0];
var coefA = tableau[i + 2][1].split("): ")[1].split(" x")[0];
var coefB = tableau[i + 2][1].split("+ ")[1].split(" (")[0];
result.push([[ATA], [coefA], [coefB]]);
}
else {
var ATA = tableau[i][0].split("-")[0];
try {
var data = [...tableau[i + 2].toString().matchAll(/\([^)]+?\)/g)];
data.forEach((d, i) => {
if (i > 1) {
var x = d[0].slice(1,-1)
var coefA = x.split(',')[0]
var coefB = x.split(',')[1]
result.push([[ATA], [coefA], [coefB]]);
}
})
}
catch (e) { }
}
}
}
result = result.sort(function (a, b) {
return a[0] - b[0];
});
var crcm = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('CR-MR');
crcm.getRange(10, 1, Math.max(11, crcm.getLastRow() - 9), result[0].length).clearContent();
crcm.getRange(10, 1, result.length, result[0].length).setValues(result);
}