0
votes

I would like to change the tab color of a sheet (sheet 2) to the same color as the background color of a cell in another sheet (sheet 1). For example, sheet 1 acts as a table of contents and lists all the other sheets in the workbook. When I set the background color of the cell in my table of contents, I would like the corresponding sheet's tab to change to that same color.

Any help would be appreciated.

Thanks!

1
did you tried to code something ?user6637260

1 Answers

1
votes

Yes, I did try to code something, and I actually figured it out. This is what I ended up doing:

function getSheetTab() {
  var app = SpreadsheetApp;
  var ss = app.getActiveSpreadsheet();
  var activeSheet = ss.getActiveSheet();
  var tabColor = activeSheet.getActiveCell().getBackground();
  var sheetName = activeSheet.getActiveCell().getValue();
  var newSheet = app.getActiveSpreadsheet().getSheetByName(sheetName);
  newSheet.setTabColor(tabColor);

}

Took me quite a bit of time, as I'm a bit of a noob to Google Sheets.

Thanks!