[英]How do I find the color of the cell which has been conditionally formatted
I want to give a message box "Please resolve errors" if any cell in the range ("H1:H100") has fill color RGB = (255,179,181). 如果范围(“ H1:H100”)内的任何单元格的填充颜色RGB =(255,179,181),我想给一个消息框“请解决错误”。
But the trick is that the cell in this range has this RGB on some conditional formatting condition. 但是诀窍在于,在某些条件格式设置条件下,此范围内的单元格具有此RGB。 By default it has a different RGB.
默认情况下,它具有不同的RGB。
Tried using 尝试使用
for i=1 to 100
if Cells(i, 8).Interior.Color = RGB(255, 179, 181) then
msgbox "resolve errors"
end if
next i
Even if the cell color is RGB(255,179,181) it is not going inside the loop because this RGB is on conditional formatting. 即使单元格颜色是RGB(255,179,181),它也不会进入循环,因为该RGB是基于条件格式的。
.DisplayFormat.Color
will return the "regular" fill color.DisplayFormat.Color
将返回“常规”填充颜色
.DisplayFormat.Interior.Color
will return the color that conditional formatting has set the cell..DisplayFormat.Interior.Color
将返回条件格式设置单元格的颜色。
so: 所以:
for i=1 to 100
if Cells(i, 8).DisplayFormat.Interior.Color = RGB(255, 179, 181) then
msgbox "resolve errors"
end if
next i
but it's kind of a weird/terrible way to check if the user has errors. 但这是一种奇怪/可怕的方式来检查用户是否有错误。 Why not check the values of the cells, the same way conditional formatting does?
为什么不像条件格式一样检查单元格的值?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.