Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

388
Visualizações
How can i set the background cell values color using **.push** array in app script?

I have been trying to change the background color of the cell value based on the STATUS. If the status is OLD FILE then i would like to set the background color of the cell red, and if the status is NEW FILE, i would like to set it into green (as shown in the sample).

enter image description here

Here is the code:

const cells = sheet.getRange("I2:I" + sheet.getLastRow())
const cellValues = cells.getValues()
Logger.log(cellValues)

const newValues = []
var backGrounds = []

cellValues.forEach((row) => {
  if (row[0] === "new file") {
     newValues.push(['OLD FILE'])
   }
   else if (row[0] === "OLD FILE" || row[0] === "NEW FILE") {
     newValues.push([row[0]])
   }
   else {
     newValues.push(['NEW FILE'])
     backGrounds.push(['00ff00'])
   }
   })

   cells.setValues(newValues).setBackground(backGrounds)
   }

I have tried using the backGrounds.push(['00ff00']) and .setBackground(backGrounds) but it still not changing.

How can i change the the cell background color based on the status?

about 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda