|
我也是新手,如果有不妥之处,请指教:
条件格式只能设3个条件,而你的里面需有个条件才能完成整个颜色的判断:
1.储存格=1时,
2.当储存格>1 and <=3时,
3.当储存格=4时
4.当储存格>4 and <=6时
5.当储存格=8时
6.当储存格>6 and <=9 and <>8时
所以用条件格式无法满足你的条件,下面是我初次做的宏,也许能帮你:
Sub a()
Dim i As Integer, j As Integer
For i = 1 To 3
For j = 1 To 3
Cells(i, j).Select
If Cells(i, j).Formula = 1 Then
Cells(i, j).Interior.ColorIndex = 3
ElseIf Cells(i, j).Formula > 1 And Cells(i, j).Formula <= 3 Then
Cells(i, j).Interior.ColorIndex = 6
ElseIf Cells(i, j).Formula = 4 Then
Cells(i, j).Interior.ColorIndex = 9
ElseIf Cells(i, j).Formula > 4 And Cells(i, j).Formula <= 6 Then
Cells(i, j).Interior.ColorIndex = 12
ElseIf Cells(i, j).Formula = 8 Then
Cells(i, j).Interior.ColorIndex = 15
ElseIf Cells(i, j).Formula > 6 And Cells(i, j).Formula <= 9 And Cells(i, j).Formula <> 8 Then
Cells(i, j).Interior.ColorIndex = 18
End If
Next
Next
End Sub
颜色参数我是随意写的,如果你需要特定的颜色,请查找相关资料
宏我已经试用过,希望能帮到你. |
|