简体   繁体   English

如何找到已被条件格式化的单元格颜色

[英]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.

相关问题 如何使用vba在Excel 2007中找到有条件格式化单元格的填充颜色值? - How do I find the fill colour value of a conditionally formatted cell in Excel 2007 using vba? 条件格式化单元格的颜色索引 - Color index of conditionally formatted cell 如何更改有条件格式的单元格的内部颜色索引 - How to change the interior colorindex of a conditionally formatted cell 如何在刚填充的当前单元格之前插入新的空白单元格 - How do i insert a new blank cell before current cell that has just been populated 如何更改单元格但尚未输入数据时如何运行Excel宏? - How do I run an Excel macro for when a cell is changed but the data has not been entered yet? 如何在另一个单元格中以文本形式检索Excel单元格值,其格式与原始单元格相同? - How do I retrieve an Excel cell value in another cell, as text, formatted as in the origin cell? 如何在应该为空白但有空格的列中找到最后一个单元格? - How to find the last cell in a column which is supposed to be blank but has spaces? VBA查找格式化的单元格 - VBA Find formatted Cell 如何在其中包含“ findstring”的特定列的listobject表中找到单元格? - How do I find the cell in a listobject table in a specific column that has “findstring” in it? 如何根据每个单元格的值和固定单元格的值有条件地格式化VBA中的列? - How do I conditionally format a column in VBA based on each cell's value and a fixed cell's value?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM