Hi.
I am trying to change the color of a tab based on a cell value, which is a date. There are multiple tabs. This is what I have written:
function onEdit(e) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var first = ss.getSheetByName("3005");
var second = ss.getSheetByName("3006");
var third = ss.getSheetByName("3007");
var fourth = ss.getSheetByName("3008");
var fifth = ss.getSheetByName ("3009");
var cell1 = first.getRange("c26");
var cell2 = second.getRange("c24");
var cell3 = third.getRange("c24");
var cell4 = fourth.getRange("c24");
var cell5 = fifth.getRange("c24");
var cellContent1 = cell1.getValue();
if (cellContent1 == 'DATE') {
first.setTabColor("#66FF00");
}
if (cellContent1 == 0) {
first.setTabColor(null);}
var cellContent2 = cell2.getValue();
if (cellContent2 == 'DATE') {
second.setTabColor("#66FF00");
}
if (cellContent2 == 0) {
second.setTabColor(null);}
var cellContent3 = cell3.getValue();
if (cellContent3 == 'DATE') {
third.setTabColor("#66FF00");
}
if (cellContent3 == 0) {
third.setTabColor(null);}
var cellContent4 = cell4.getValue();
if (cellContent4 == 'DATE') {
fourth.setTabColor("#66FF00");
}
if (cellContent4 == 0) {
fourth.setTabColor(null);}
var cellContent5 = cell1.getValue();
if (cellContent5 == 'DATE') {
fifth.setTabColor("#66FF00");
}
if (cellContent5 == 0) {
fifth.setTabColor(null);}}
The script excutes and completes- but no changes to the color on the tab.
If I base the color change on a number, for example it works perfectly i.e.
function onEdit(e) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var first = ss.getSheetByName("3005");
var cell1 = first.getRange("i20");
var cellContent1 = cell1.getValue();
if (cellContent1 == 1) {
first.setTabColor("#66FF00");
}
if (cellContent1 == 0) {
first.setTabColor(null);}
https://docs.google.com/spreadsheets...it?usp=sharing
What am I missing?
Thank you for your time.
Bookmarks