在Excel中,如何将条件格式设置为验证结果? [英] How do I base conditional formatting on validation results in Excel?

查看:130
本文介绍了在Excel中,如何将条件格式设置为验证结果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果单元格无效,我想更改单元格的格式。在这种情况下,有效表示单元格的数据验证规则失败。

I want to change the formatting of a cell if the cell is not valid. In this case, "valid" means that the cell has failed the data validation rules.

我在问这个问题,因为我找不到答案。我终于解决了。我会发布我的答案,看看是否有人想评论或提供更好的答案!

I'm asking this question because I couldn't find the answer on SO. I eventually solved it. I'll post my answer and see if people want to comment or provide a better answer!

推荐答案

这是一个基本的大纲,想要在本周晚些时候变得更好的格式化答案,当我有更多的时间。

Here's a basic outline that I want to turn into a better formatted answer later this week when I have more time.


  1. 创建数据验证规则。在我的情况下,我引用另一个工作簿中的数据列表。

  2. 关闭无效数据的警报,我们将使用条件格式来显示数据无效。 >
  3. 为具有数据验证规则的单元格添加条件格式化选项。要执行此操作,请转到管理规则 - >新建规则,并在公式中使用= IS_VALID(CELL(row,C4),CELL(col,C4)),其中C4是要进行的第一个单元格开始输入数据。

  4. 创建一个看起来像

的自定义函数: / p>

this:

Public Function IS_VALID(row, column) As Boolean
IS_VALID = Not Cells(row, column).Validation.value
End Function

最后,您可以将条件格式化效果设置为任何您想要的着色细胞红色。这个答案对我来说是有效的,我想不要忘了把它添加到SO中,但是现在没有时间让它变得很漂亮。

Finally, you can set your conditional formatting effects to whatever you want, like coloring the cell red. This answer worked for me, and I wanted to not forget to add it to SO, but don't have the time to make it all pretty right now.

这篇关于在Excel中,如何将条件格式设置为验证结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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