I am trying to perform a similar VLOOKUP as described in this
CodePudding user response:
I think I've resolved the issue. There may be a better way but this works for now.
function updateMaster() {
const mss = SpreadsheetApp.getActiveSpreadsheet();
const msh = mss.getSheetByName('Data');
const mDB = msh.getRange("A2:A" msh.getLastRow()).getValues(); //Gets ID's from Master Spreadsheet
var combinedData = []; // edited
const ish = mss.getSheetByName('Sheet IDs');
const ivs = ish.getRange('A1:A' ish.getLastRow()).getValues().flat();
ivs.forEach((id,i) => {
let ss = SpreadsheetApp.openById(id);
let sh = ss.getSheetByName('Sep 22');
let vs = sh.getRange("A2:L" sh.getLastRow()).getValues(); //Get's ID's from individual sheets
combinedData = combinedData.concat(vs); // edited
Logger.log(combinedData)
// Create an object for searching the values of column "A".
const obj = combinedData.reduce((o, [a,,,,,,,,,, ...kl]) => ((o[a] = kl), o), {});
// Create an array for putting to the Spreadsheet.
const values = mDB.map(([g]) => obj[g] || ["", ""]);
// Put the array to the Spreadsheet.
msh.getRange(2, 7, values.length, 2).setValues(values);
});
}