1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
Option Explicit
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Excel.Range)
Dim WS As Worksheet
For Each WS In Worksheets
With WS
If Cells(20, 7).Value <> Cells(20, 11) Then
Range(Cells(20, 6), Cells(20, 7)).Font.ColorIndex = 3
Range(Cells(20, 10), Cells(20, 11)).Font.ColorIndex = 3
Range(Cells(20, 16), Cells(20, 17)).Font.ColorIndex = 3
Else
Range(Cells(20, 6), Cells(20, 7)).Font.ColorIndex = xlAutomatic
Range(Cells(20, 10), Cells(20, 11)).Font.ColorIndex = xlAutomatic
Range(Cells(20, 16), Cells(20, 17)).Font.ColorIndex = xlAutomatic
End If
If Cells(20, 7).Value <> Cells(20, 17) Then
Range(Cells(20, 6), Cells(20, 7)).Font.ColorIndex = 3
Range(Cells(20, 16), Cells(20, 17)).Font.ColorIndex = 3
Range(Cells(20, 10), Cells(20, 11)).Font.ColorIndex = 3
Else
Range(Cells(20, 6), Cells(20, 7)).Font.ColorIndex = xlAutomatic
Range(Cells(20, 16), Cells(20, 17)).Font.ColorIndex = xlAutomatic
Range(Cells(20, 10), Cells(20, 11)).Font.ColorIndex = xlAutomatic
End If
If Cells(20, 11).Value <> Cells(20, 17) Then
Range(Cells(20, 10), Cells(20, 11)).Font.ColorIndex = 3
Range(Cells(20, 16), Cells(20, 17)).Font.ColorIndex = 3
Range(Cells(20, 6), Cells(20, 7)).Font.ColorIndex = 3
Else
Range(Cells(20, 10), Cells(20, 11)).Font.ColorIndex = xlAutomatic
Range(Cells(20, 16), Cells(20, 17)).Font.ColorIndex = xlAutomatic
Range(Cells(20, 6), Cells(20, 7)).Font.ColorIndex = xlAutomatic
End If
End With
Next WS
End Sub |
Partager