【发布时间】:2018-08-10 19:56:51
【问题描述】:
我是 VBA 新手,尝试过以下方法,但不起作用。你能帮我修一下吗。我正在尝试根据其值使每个单元格具有不同的 RGB 颜色:
Sub ColorCells()
Dim rwIndex As Integer
Dim colIndex As Integer
Dim r As Integer
Dim g As Integer
Dim b As Integer
For rwIndex = 1 To 1000
For colIndex = 1 To 1000
r = Cells(rwIndex, colIndex).Value Mod 256
g = Cells(rwIndex, colIndex).Value \ 256 Mod 256
b = Cells(rwIndex, colIndex).Value \ 65536 Mod 256
Cells(rwIndex, colIndex).Interior.ColorIndex = RGB(r, g, b)
Next colIndex
Next rwIndex
End Sub
【问题讨论】: