jeudi 28 février 2019

look at all instances of an array in a if statement?

I have about 20 different sheets and I wrote some google script to combine all of the data into a master sheet. Now I'd like like to be able to exclude certain sheets. My idea to do this was to storage the names of those sheet in a variable. This is what I have so far, but I am getting an error? Any ideas?

label is the name of the Column that I am scanning each sheet for and masterSheetName is the sheet where I am storing the data.

 if (sheetName !== masterSheetName && sheetName !== skippedsheets) 

lines are the ones I am having trouble with. It is not going though all of the instances of skipped sheets.

Is there a way to do this with a for each loop?

function getColVals(label, masterSheetName) {

  var sheets = SpreadsheetApp.getActiveSpreadsheet().getSheets();
  var colValues = []
  for ([i,sheet] in sheets) {
    var sheetName = sheet.getSheetName();
    var skippedsheets = ["HHS 1","HHS 2"];
    Logger.log(skippedsheets);
    Logger.log(skippedsheets[0]);
    if (sheetName !== masterSheetName && sheetName !== skippedsheets) {
    var colValues2 = getColValues(label,sheetName);
    colValues = colValues.concat(colValues2);
    } 

  }
  return colValues; 

}

thank you, Jerome

Aucun commentaire:

Enregistrer un commentaire