excel vba中(J95:R见图示)列值相同或差5时填充不同颜色

1。当倒数第二个数值与它上面7个数值对比时,相同时或者相差5时才做填充颜色
2。范围(J95:R最后一个非空单元)范围可自定义

第1个回答  推荐于2016-05-05
Sub xx()
n = [r65536].End(3).Row
If n < 97 Then Exit Sub
For i = 10 To 18
For j = 95 To n - 2
If Cells(j, i) = Cells(n - 1, i) Then Cells(j, i).Interior.ColorIndex = 7: Cells(n - 1, i).Interior.ColorIndex = 3
If Cells(j, i) - Cells(n - 1, i) = 5 Or Cells(j, i) - Cells(n - 1, i) = -5 Then Cells(j, i).Interior.ColorIndex = 10: Cells(n - 1, i).Interior.ColorIndex = 3
Next
Next
End Sub本回答被提问者采纳
相似回答
大家正在搜