Public Sub 条件填充颜色()
Dim H As Long, L As Long, maxH As Long
For L = 11 To 25
maxH = Cells(Rows.Count, L).End(xlUp).Row
For H = maxH To 20 Step -1
If Cells(H, L).Value = Cells(H + 1, L).Value And Cells(H, L).Value = Cells(H - 1, L).Value Then
Cells(H, L).Interior.ColorIndex = 42
End If
Next
Next
End Sub
追问差不多是这样的意思,可能是我表达有误
例如
倒数第一为A(填充为“青色”)
倒数第二为C(填充为黄色)
倒数第三为A(填充为“青色”)
追答哦
追问cfzzj007老师:请问如何修改代码才对
追答不明白,AC是什么意思。
追问倒数第一为A(填充为“青色”)
倒数第二为C(填充为黄色)
倒数第三为A(填充为“青色”)
不明白,AC是什么意思。表示倒数第一与倒数第三相同时(填充为“青色”),倒数第二为的内容(填充为黄色)
追答Public Sub 条件填充颜色()
Dim H As Long, L As Long, maxH As Long
For L = 11 To 25
maxH = Cells(Rows.Count, L).End(xlUp).Row
For H = maxH To 20 Step -1
If Cells(H, L).Value <> Cells(H + 1, L).Value And Cells(H+1, L).Value = Cells(H - 1, L).Value Then
Cells(H, L).Interior.ColorIndex = 42
Cells(H-1, L).Interior.ColorIndex = 6
Cells(H+1, L).Interior.ColorIndex = 6
End If
Next
Next
End Sub