title: Ignore multiple sheets besides "MasterSheet" with script "Combine Multiple Tabs to a Master Tab When Column Positions Don’t Match"
body: <p>I've been using a script lately I've found at <a href="http://www.chicagocomputerclasses.com/google-sheets-apps-script-combine-multiple-tabs-to-a-master-tab-when-column-positions-dont-match/" rel="nofollow noreferrer">http://www.chicagocomputerclasses.com/google-sheets-apps-script-combine-multiple-tabs-to-a-master-tab-when-column-positions-dont-match/</a></p>
  <pre><code>function combineData() {
    
    var masterSheet = &quot;Master&quot;;
    
    var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(masterSheet);
    var lc = ss.getLastColumn();
    var lr = ss.getLastRow() &gt; 1 ? ss.getLastRow() : 2;
    
    ss.getRange(2, 1, lr-1, lc).clearContent();
    
    var labels = ss.getRange(1, 1, 1, lc).getValues()[0];
    
    
    labels.forEach(function(label,i){
      var colValues = getCombinedColumnValues(label,masterSheet);
      ss.getRange(2, i+1, colValues.length, 1).setValues(colValues);
      
    })
    
  }
  
  
  function getCombinedColumnValues(label,masterSheetName) {
    
    var sheets = SpreadsheetApp.getActiveSpreadsheet().getSheets();
    
    var colValues = [];
    
    for (let [i, sheet] of Object.entries(sheets)) {
      var sheetName = sheet.getSheetName();
      if(sheetName !== masterSheetName) {
        var tempValues = getColumnValues(label,sheetName);
        colValues = colValues.concat(tempValues);
      }
    }
    
    return colValues;
  }
  
  
  function getColumnValues(label,sheetName) {
    
    var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName);
    var colIndex = getColumnIndex(label,sheetName);
    var numRows = ss.getLastRow() - 1;
    var colValues = ss.getRange(2, colIndex, numRows, 1).getValues();
    return colValues;
  }
  
  
  function getColumnIndex(label,sheetName) {
    
    var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName);
    
    var lc = ss.getLastColumn();
    var lookupRangeValues = ss.getRange(1, 1, 1, lc).getValues()[0];
    
    var index = lookupRangeValues.indexOf(label) + 1;
    
    return index;
    
  }
  </code></pre>
  <p>It's a great script. Unfortunately the script only ignores &quot;MasterSheet&quot; when being executed.</p>
  <p>Please can someone modify the script so there ist an option to ignore multiple sheets besides &quot;MasterSheet&quot;?</p>
  <p>That would be awesome!</p>