[英]Two different interior cell color give me the same colorIndex VBA
Why two diffrent cells color give me the same ColorIndex ? 为什么两个不同的单元格颜色给我相同的ColorIndex?
I use this function to get the cell color index: 我使用此函数获取单元格颜色索引:
Function InteriorColor(CellColor As Range)
Application.Volatile
InteriorColor = CellColor.Interior.ColorIndex
End Function
This is what the function return: 这是函数返回的内容:
ColorIndex is limited to 256 Colors, so a broad range of RGB Colors get converted to the same ColorIndex. ColorIndex限制为256种颜色,因此可以将多种RGB颜色转换为相同的ColorIndex。 Use .Color instead, there you are able to use RGB Colors, which are more precise.
使用.Color代替,在那里您可以使用更精确的RGB颜色。
Cells(1,1).Interior.Color = RGB(255,255,255)
ColorIndex
covers a very limited set of values for a very limited set of colors. ColorIndex
涵盖了非常有限的一组颜色值。
Consider using Color
instead. 考虑改用
Color
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.