返回列表 上一主題 發帖

[發問] 2~4個區域的同欄位相同數字標示底色語法。

Sub 同列著色()

Dim Y%, J%, Z%

Y = Cells(Rows.Count, 1).End(3).Row

For J = 2 To Y

For Z = 2 To 7

If Cells(J, Z) = Cells(J, Z + 8) And Cells(J, Z) = Cells(J, Z + 16) And Cells(J, Z) = Cells(J, Z + 24) Then

    Cells(J, Z).Interior.ColorIndex = 8
   
    Cells(J, Z + 8).Interior.ColorIndex = 8
   
    Cells(J, Z + 16).Interior.ColorIndex = 8
   
    Cells(J, Z + 24).Interior.ColorIndex = 8
   
ElseIf Cells(J, Z) = Cells(J, Z + 8) And Cells(J, Z) = Cells(J, Z + 16) Then

    Cells(J, Z).Interior.ColorIndex = 4
   
    Cells(J, Z + 8).Interior.ColorIndex = 4
   
    Cells(J, Z + 16).Interior.ColorIndex = 4

ElseIf Cells(J, Z) = Cells(J, Z + 8) Then

    Cells(J, Z).Interior.ColorIndex = 6
   
    Cells(J, Z + 8).Interior.ColorIndex = 6
   
Else: GoTo 101

End If

101: Next

Next

End Sub
同列相同著色.rar (196.62 KB)
cjw

TOP

        靜思自在 : 天上最美是星星,人生最美是溫情。
返回列表 上一主題