[英]Excel VBA — three consecutive cells have the same interior.colorindex, but the range of these three cells returns different colors
我有三个连续的单元格(A1,B1,C1),它们的internal.colorindex均为15。但是,如果我检查是否cells(A1).resize(1,3).interior.colorindex = 15,则返回False ...不知道为什么...
Cell interiors can have the same ColorIndex
but still have different Color
. 单元内部可以具有相同的
ColorIndex
但仍具有不同的Color
。 Maybe this is your problem? 也许这是您的问题?
Range("A1").Resize(1, 3).Interior.ColorIndex
will only return 15 if all three cells have the same ColorIndex
and Color
. 如果所有三个单元格都具有相同的
ColorIndex
和 Color
Range("A1").Resize(1, 3).Interior.ColorIndex
将仅返回15。 If Color
differs, then it will return Null
, even if ColorIndex
is the same. 如果
Color
不同,则即使ColorIndex
相同,它也将返回Null
。
Excel workbooks have a predefined palette of 56 colors. Excel工作簿具有56种颜色的预定义调色板。 Each of these is associated with a color index between 1 and 56 (0 means no color).
这些颜色中的每一个都与1到56之间的颜色索引相关联(0表示没有颜色)。 (You can edit a workbook's color palette to change what color each index refers to.)
(您可以 编辑工作簿的调色板以更改每个索引所指的颜色。)
If you assign to a cell interior a Color
that is not part of the palette, and then ask what ColorIndex
it corresponds to, then the index will snap to that of the closest color in the palette (smallest RGB distance, I think). 如果为单元格内部分配的
Color
不属于调色板,然后询问其对应的ColorIndex
,则索引将与调色板中最接近的颜色(我认为是最小的RGB距离)相匹配。 This is why two somewhat different Color
s can return the same ColorIndex
. 这就是为什么两个略有不同的
Color
可以返回相同的ColorIndex
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.