EXCEL VBA中区域1出现的与对应不填充

区域1出现的与对应不填充... 区域1出现的与对应不填充 展开
 我来答
庆年工坊
2015-08-30 · 知道合伙人互联网行家
庆年工坊
知道合伙人互联网行家
采纳数:4233 获赞数:8932

向TA提问 私信TA
展开全部
Sub xx()
    n = Cells(4 ^ 8, 11).End(3).Row
    col = Array(8, 7, 9, 10, 6)
    For i = 11 To 33 Step 2
        a = Cells(n - 11, i)
        b = Cells(n - 11, i + 1)
        Cells(n - 11, i).Resize(1, 2).Interior.ColorIndex = col(((i - 11) / 2) Mod 5)
        For j = n - 9 To n
            If Cells(j, i) <> a And Cells(j, i) <> b Then Cells(j, i).Interior.ColorIndex = 3
            If Cells(j, i + 1) <> a And Cells(j, i + 1) <> b Then Cells(j, i + 1).Interior.ColorIndex = 3
        Next
    Next
End Sub
追问
部分填充过多了
追答
Sub xx()
    n = Cells(4 ^ 8, 11).End(3).Row
    col = Array(8, 7, 9, 10, 6)
    For i = 11 To 33 Step 2
        a = (((Cells(n - 11, i) + 1) \ 2) * 2) Mod 10
        b = (a + 9) Mod 10
        Cells(n - 11, i).Interior.ColorIndex = col(((i - 11) / 2) Mod 5)
        If Cells(n - 11, i + 1) = a Or Cells(n - 11, i + 1) = b Then Cells(n - 11, i + 1).Interior.ColorIndex = col(((i - 11) / 2) Mod 5)
        For j = n - 9 To n
            If Cells(j, i) <> a And Cells(j, i) <> b Then Cells(j, i).Interior.ColorIndex = 3
            If Cells(j, i + 1) <> a And Cells(j, i + 1) <> b Then Cells(j, i + 1).Interior.ColorIndex = 3
        Next
    Next
End Sub
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式