Andreas Martin
Andreas Martin

Reputation: 1

Copy Styles in Google Calc based on Cell Value

i have seen in other spreadsheets, that it is possible and wanted to adapted it to my own sheet.

In My Case i have a List of Teammembers with different coloring, based on their Licences and roles in the Team. I now want to enter their name in some sort of Date-Organiser and want their respective background colors and "text-styles" like bold or cursiv automatically copied from the Team-List to the organizer.

I´ve got the following code and tried to adjust it to my sheet, but it is not working:

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheetData = ss.getSheetByName("Spielerliste");
var sheetTermine = ss.getSheetByName("Termine");
var playerNames = sheetData.getRange("A4:A");



function MATCHES_COLOR(player, color) {
  return GET_BACKGROUNDCOLOR_FOR_PLAYERNAME(player) == color;
}

function GET_BACKGROUNDCOLOR_FOR_PLAYERNAME(player) {
  if(player === "" ) {
    return null;
  }
  let referenceCells = playerNames.getValues();
  for(let i = 0; i < referenceCells.length; i++) {
    if(referenceCells[i] === "") {
      return null;
    }
    if(player == referenceCells[i]) {
      return playerNames.getBackgrounds()[i];
    }
  }
  return null;
}

Upvotes: 0

Views: 8

Answers (0)

Related Questions