2016-07-08 5 views
-1

を変更する私のようなデータセットを持っている:交互ハイライト値は

group  issues 
1   bad 
1   bad 
2   good 
3   bad 
3   bad 
3   bad 
3   bad 
4   bad 
4   bad 
5   bad 
5   bad 
6   good 

私はグループ全体の色で、悪いグループを強調したいと思います。しかし、1つの行に2つの悪いグループがある場合は、そのグループに色を変えてもらい、良いグループであれば色を付けないようにします。たとえば、

group  issues 
1   bad (blue) 
1   bad (blue) 
2   good (white) 
3   bad (blue) 
3   bad (blue) 
3   bad (blue) 
3   bad (blue) 
4   bad (green) 
4   bad (green) 
5   bad (blue) 
5   bad (blue) 
6   good (white) 

たとえば、次のようになります。色は本当に重要ではありません。相当に大きなデータセットに対してこれを自動的に行うにはどうしたらいいですか?

+1

[条件付きフォーマット](https://support.office.com/en-us/article/Use-a-formula-to-apply-conditional-formatting-fed60dfa-1d3f-4e13-9ecb-f1951ff89d7f)を試したことがありますか? )? – BruceWayne

答えて

0

あなたは、このようなマクロを使用することができます:

Sub highlights() 
Dim row 
Dim AltColor As Integer 
AltColor = 5 
For row = 2 To 56 
If Cells(row, 2).Value = "bad" Then 
If Cells(row - 1, 1).Value <> Cells(row, 1).Value And Cells(row - 1, Value = "bad" Then 
If AltColor = 5 Then 
    AltColor = 10 
Cells(row, 3).Interior.ColorIndex = AltColor 
Else: 
    AltColor = 5 
    Cells(row, 3).Interior.ColorIndex = AltColor 
End If 
Else 
    Cells(row, 3).Interior.ColorIndex = AltColor 
End If 
End If 
Next row 
End Sub 

私はあなたのデータは青と緑の色に二row.numbers 5と10 reforから開始したとします。

関連する問題