我有两个单元格:绿色和紫色。我有代码:

Sub test()
    With Selection.Interior
        MsgBox (.ColorIndex)
   End With
End Sub


为何编号为MsgBox15同时显示绿色和紫色。
当我使用代码

Sub test()
    With Selection.Interior
        MsgBox (.Color)
   End With
End Sub


它给出不同的数字,但对于绿色和紫色是唯一的:1021331613082801

为什么ColorIndex给出相同的数字,为什么Color给出不同且唯一的数字?

无论如何,在代码中使用.Color返回的数字是否安全?它会根据计算机而改变吗?

最佳答案

.Color的调色板比.ColorIndex宽得多(定义了更多的颜色)。 ColorIndex必须近似以弥补较少定义的颜色和阴影。

excel - Excel VBA .Interior.ColorIndex无法正常工作-LMLPHP

07-24 20:28