-1

I am super new to Google Apps Script, and the Java it's based on. In fact I just dived into the deep end of the pool not even eight hours ago! I know VBA, SQL, etc, but I digress.

I've figured out how to change the background color of row when the cell contains a certain value. I can also change the color if the value changes to something else. What I can't do is unchange the color if the value is deleted.

How do I use google apps script to test for a blank cell?

Cooper
  • 59,616
  • 6
  • 23
  • 54
Tod
  • 19
  • 1
  • 4
  • 1
    Take a look at the Stack Overflow post in the following link: [Google Spreadheets Scripts: check if cell is empty](https://stackoverflow.com/questions/41664971/google-spreadheets-scripts-check-if-cell-is-empty) – Alan Wells Nov 20 '17 at 20:43
  • Possible duplicate of [Google Spreadheets Scripts: check if cell is empty](https://stackoverflow.com/questions/41664971/google-spreadheets-scripts-check-if-cell-is-empty) – Rubén Nov 20 '17 at 21:57
  • 1
    An empty cell value is simply an empty string like this `''` if you want to work with the entire array of values and find blank values, otherwise, for the `range` class you can use `.isBlank()` [(read here)](https://developers.google.com/apps-script/reference/spreadsheet/range#isBlank()) to find out if the **entire** range is blank. – Vytautas Nov 21 '17 at 05:29

1 Answers1

1

Try this:

function getMyColorValue()
{
   var ss=SpreadsheetApp.getActive();
   var sh=ss.getSheetByName('My Sheet Name');
   var rg=sh.getRange('A1');
   var colorValue="#ffffff";
   if(!rg.isBlank())
   {  
      colorValue=rg.getValue();
   }
   rg.setBackgroundColor(colorValue);
}
Cooper
  • 59,616
  • 6
  • 23
  • 54