lundi 3 août 2020

Getting a sheet list per tab color

I'm trying to put up a list of my current tabs and filter it per tab color. So far, I've been able to put the list, but the conditions I've been trying to put on it are not working. What I've tried so far:

function CHARACTERLIST() {
 var ss = SpreadsheetApp.getActiveSpreadsheet();
 var sheet = ss.getActiveSheet();
 var sheetnum = ss.getNumSheets();
   
   for (var i = 0; i < sheetnum; i++) {
   var color = ss.getSheets()[0+i].getTabColor();
   if (color = "#00ff00") {
    ss.getSheetByName("Character List").getRange(2+i, 1).setValue(ss.getSheets()[0+i].getName())
   }else{ return null;
   };
 };
};

I've logged the color list and it is coming out correctly, but when I try to use "if" to let the colors other than green (#00ff00) empty, it is not working. I know that the way I'm doing it, I will have blank cells on my list, and I will try to figure out what I should do about it later. My main question here is: why isn't the "if" working? Can anybody help me out?

Aucun commentaire:

Enregistrer un commentaire