EXCEL VBA填充内容单元格颜色和字体颜色

1.用M1的内容去填充区域ABCD内容
2.区域ABCD范围为I4:L66(空单元不填充,跳过空单元)
3.同行找出填充内容是否在同一个位置(如M列所示)
4.M列结果等于1时,单元格填充红色,等于2时,单元格填充青色,,等于3时,单元格填充黄色,,等于4时,单元格填充蓝色,

Sub s()
    t = [M1]
    c = Array(0, 3, 14, 6, 33)
    Dim k(9 To 12)
    For i = 1 To 4
        k(i + 8) = Mid(t, i, 1)
    Next
    Set d = CreateObject("scripting.dictionary")
    For i = 4 To 66
        For j = 9 To 12
            If Cells(i, j) = "" Then GoTo 1
            d(InStr(Cells(i, j), k(j))) = ""
        Next
        Cells(i, 13) = d.Count
        Cells(i, 13).Interior.ColorIndex = c(d.Count)
1:
        d.RemoveAll
    Next
End Sub来自:求助得到的回答
温馨提示:答案为网友推荐,仅供参考
第1个回答  2017-05-13
Sub Test()Dim i, j As Doublei = 1048576Cells(Cells(i, 3).End(xlUp).Row, 3).Interior.Color = vbGreenCells(Cells(i, 3).End(xlUp).Row + 1, 3).Interior.Color = 15773696For j = 1 To 4Cells(Cells(i, 4).End(xlUp).Row - j + 1, 4).Interior.Color = vbGreenNextEnd Sub
第2个回答  2017-05-13
Sub Test()Dim i, j As Doublei = 1048576Cells(Cells(i, 3).End(xlUp).Row, 3).Interior.Color = vbGreenCells(Cells(i, 3).End(xlUp).Row + 1, 3).Interior.Color = 15773696For j = 1 To 4Cells(Cells(i, 4).End(xlUp).Row - j + 1, 4).Interior.Color = vbGreenNextEnd Sub
相似回答
大家正在搜