excel vba组合填充单元颜色

1.c:f列为数据 这个范围可以自由修改

步骤如下:

1.Alt+F11,输入如下代码:

2.F5执行代码,Sheet1中的A1:A10就填充上了不同的颜色:

温馨提示:答案为网友推荐,仅供参考
第1个回答  2016-02-22
Sub s()
    Dim rg As Range, c As Range
    Set rg = [k5:t14]
    cd = 20
    c1 = 3
    c2 = 4
    n = Cells(Rows.Count, c1).End(3).Row
    Set d = CreateObject("scripting.dictionary")
    For i = n - cd + 1 To n
        d(Cells(i, c1).Text & Cells(i, c2).Text) = ""
    Next
    For Each c In rg
        If d.exists(c.Text) Then c.Interior.ColorIndex = 6
    Next
End Sub

本回答被提问者采纳
相似回答