VBA根据当前颜色更改单元格颜色

时间:2017-11-09 12:33:28

标签: excel vba colors color-scheme

我有很多excel电子表格,其颜色主题与我公司的颜色主题不符。 例如,我需要将RBG值204,255,255更改为179,212,85的单元格。有没有办法用VBA做到这一点?

1 个答案:

答案 0 :(得分:2)

尝试使用以下代码将Rng中的所有单元格颜色从RGB(204, 255, 255)更改为RGB(179, 212, 85)

Sub ChangeCellColor()

Dim Rng As Range, C As Range

Application.ScreenUpdating = False

Set Rng = Range("A1:E10") ' modify this range according to your needs
For Each C In Rng
    If C.Interior.Color = RGB(204, 255, 255) Then C.Interior.Color = RGB(179, 212, 85)
Next C
Application.ScreenUpdating = True

End Sub
相关问题