测试空单元 [英] Testing for empty cell

查看:46
本文介绍了测试空单元的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Google Apps脚本及其所基于的Java的超级新手.实际上,我什至不到八个小时就潜入游泳池的尽头!我知道VBA,SQL等,但是我离题了.

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.

如何使用Google Apps脚本测试空白单元格?

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

推荐答案

尝试一下:

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);
}

这篇关于测试空单元的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆