Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8959381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:25:25+00:00 2026-06-15T15:25:25+00:00

I have already tried this: Script to Change Row Color when a cell changes

  • 0

I have already tried this: Script to Change Row Color when a cell changes text but it can’t get it to work. The color of the row does not change to #000000. This is what I have so far:

function onEdit(event)
{
  var ss = event.source.getActiveSheet();
  var r = event.source.getActiveRange();

  var currentValue = r.getValue();

  if(currentValue == "dags dato")
  {
    var dd = Utilities.formatDate(new Date(), "GMT", "yyyy-MM-dd");
    r.setValue(dd);
  }
  else if(currentValue == "dialog")
  {
    setRowColor("yellow");
  }
  else if(currentValue == "besvaret")
  {
    setRowColor("yellow");
  }
  else if(currentValue == "afvist")
  {
    setRowColor("red");
  }
}

function setRowColor(color)
{
  var range = SpreadsheetApp.getActiveSheet().getDataRange();
  var statusColumnOffset = getStatusColumnOffset();

  for (var i = range.getRow(); i < range.getLastRow(); i++) {
    rowRange = range.offset(i, 0, 1);
    status = rowRange.offset(0, statusColumnOffset).getValue();

    rowRange.setBackgroundColor("#000000");

}


//Returns the offset value of the column titled "Status"
//(eg, if the 7th column is labeled "Status", this function returns 6)
function getStatusColumnOffset() {

  lastColumn = SpreadsheetApp.getActiveSheet().getLastColumn();
  var range = SpreadsheetApp.getActiveSheet().getRange(1,1,1,lastColumn);

  for (var i = 0; i < range.getLastColumn(); i++) {
    if (range.offset(0, i, 1, 1).getValue() == "Status") {
      return i;
    } 
  }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T15:25:26+00:00Added an answer on June 15, 2026 at 3:25 pm

    I wrote way faster and cleaner method for myself and I wanted to share it.

    function onEdit(e) {
        if (e) { 
            var ss = e.source.getActiveSheet();
            var r = e.source.getActiveRange(); 
    
            // If you want to be specific
            // do not work in first row
            // do not work in other sheets except "MySheet"
            if (r.getRow() != 1 && ss.getName() == "MySheet") {
    
                // E.g. status column is 2nd (B)
                status = ss.getRange(r.getRow(), 2).getValue();
    
                // Specify the range with which You want to highlight
                // with some reading of API you can easily modify the range selection properties
                // (e.g. to automatically select all columns)
                rowRange = ss.getRange(r.getRow(),1,1,19);
    
                // This changes font color
                if (status == 'YES') {
                    rowRange.setFontColor("#999999");
                } else if (status == 'N/A') {
                    rowRange.setFontColor("#999999");
                // DEFAULT
                } else if (status == '') { 
                    rowRange.setFontColor("#000000");
                }   
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I already tried stop(true,true), stop(true) and clearQueue(); but this doesn't work. I have problem
I have tried looking though several of the already asked question about this topic
Can I disable the minimize button in JFrame? I have already tried setUndecorated() and
I have already googled and searched stackoverflow but I can find nothing related to
Goodday, I have this script beneath to recognize the first tag ([Test1]) But all
I have already tried multiple ways. defaults write com.apple.Xcode PBXCustomTemplateMacroDefinitions '{ORGANIZATIONNAME=YourNameHere;}' Also i've tried
I cannot import a maven project with WTP features enabled. I have already tried:
I have already some applets ready. I tried to run it on android tablet.
i seem to have some trouble installing autopy.h https://github.com/msanders/autopy/#introduction i already tried the installation
I have a simple script, which tries to kill an already running process. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.