Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

389
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda