0

Not very familiar with Google App Scripts but trying to merge content from multiple tabs into one master sheet.

In addition, there are some tabs I want to ignore in the file. I know that by using logger, that the row referencing filteredSheets is working.

I want it to also ignore the header of each spread during merging of content and I've gotten this far. I suspect that I should be calling. Any help with this is greatly appreciated!

function mergeDirSheets() {

  const master = "Global Data";
  const ignoreSheets = ["Feedback"];
  const dataRange = "A2:T";
  const checkRange = "A2:A";
 
  const ss = SpreadsheetApp.getActiveSpreadsheet();
  const allSheets = ss.getSheets();
 
  ignoreSheets.push(master);
  const filteredSheets = allSheets.filter(s => ignoreSheets.indexOf(s.getSheetName()) == -1);

  const valueMaster = master.getRange(2, 1, master.getLastRow(), master.getLastColumn()).getValues();
 
  var sheets = ss.getSheets().reduce(function(acc, elem){
    if (elem.getSheetName() != "Global Data") {
       acc.push(elem);
       }
       return acc;
  },[]);

  for (var i = 0; i < sheets.length; i++){
    var data = valueMaster.filter( function(item){
      return item[2] === sheets[i].getfilteredSheets();
     });
     sheets[i].getRange("A2:C").clearContent();
     sheets[i].getRange(2, 1, data.length, data[0].length).setValues(data);
  }


}
Berryblue
  • 17
  • 5
  • There's no method named getFilteredSheets in class Sheet `return item[2] === sheets[i].getfilteredSheets();` – Cooper Nov 20 '20 at 22:14
  • You should avoid this notation in getRange() `"A2:A"` as tends to produce nulls from the bottom of data to maxRows. – Cooper Nov 20 '20 at 22:16
  • You seem to be trying to put master data into all of the sheets rather than the other way around. – Cooper Nov 20 '20 at 22:20
  • Thanks Cooper for the feedback! I will definitely rethink this and look it further over the weekend. – Berryblue Nov 21 '20 at 03:26

0 Answers0