简体   繁体   中英

Two different interior cell color give me the same colorIndex VBA

Why two diffrent cells color give me the same 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. Use .Color instead, there you are able to use RGB Colors, which are more precise.

Cells(1,1).Interior.Color = RGB(255,255,255)

ColorIndex covers a very limited set of values for a very limited set of colors.

Consider using Color instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM