Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

387
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!