|
楼主 |
发表于 2020-2-22 16:49
|
显示全部楼层
谢谢了,再帮看看,这个如何继续用for 简化,这个颜色对比应该可以写的,写不出来。。。
Sub asdf()
For i = 2 To 10
Cells(6, (i - 1) * 2) = 29
If (Cells(6, (i - 1) * 2) > Cells(3, (i - 1) * 2)) Then
Cells(6, (i - 1) * 2).Font.Color = RGB(255, 0, 0)
Else
Cells(6, (i - 1) * 2).Font.Color = RGB(0, 255, 0)
End If
Cells(7, (i - 1) * 2) = 27
If (Cells(7, (i - 1) * 2) > Cells(3, (i - 1) * 2)) Then
Cells(7, (i - 1) * 2).Font.Color = RGB(255, 0, 0)
Else
Cells(7, (i - 1) * 2).Font.Color = RGB(0, 255, 0)
End If
Cells(8, (i - 1) * 2) = 25
If (Cells(8, (i - 1) * 2) > Cells(3, (i - 1) * 2)) Then
Cells(8, (i - 1) * 2).Font.Color = RGB(255, 0, 0)
Else
Cells(8, (i - 1) * 2).Font.Color = RGB(0, 255, 0)
End If
Cells(9, (i - 1) * 2) = 23
If (Cells(9, (i - 1) * 2) > Cells(3, (i - 1) * 2)) Then
Cells(9, (i - 1) * 2).Font.Color = RGB(255, 0, 0)
Else
Cells(9, (i - 1) * 2).Font.Color = RGB(0, 255, 0)
End If
Cells(10, (i - 1) * 2) = 21
If (Cells(10, (i - 1) * 2) > Cells(3, (i - 1) * 2)) Then
Cells(10, (i - 1) * 2).Font.Color = RGB(255, 0, 0)
Else
Cells(10, (i - 1) * 2).Font.Color = RGB(0, 255, 0)
End If
Cells(11, (i - 1) * 2) = 11
If (Cells(11, (i - 1) * 2) > Cells(3, (i - 1) * 2)) Then
Cells(11, (i - 1) * 2).Font.Color = RGB(255, 0, 0)
Else
Cells(11, (i - 1) * 2).Font.Color = RGB(0, 255, 0)
End If
Cells(12, (i - 1) * 2) = 13
If (Cells(12, (i - 1) * 2) > Cells(3, (i - 1) * 2)) Then
Cells(12, (i - 1) * 2).Font.Color = RGB(255, 0, 0)
Else
Cells(12, (i - 1) * 2).Font.Color = RGB(0, 255, 0)
End If
Next
End Sub
|
|