'#################################################
'### Constante de la plage concernée à adapter ###
Const MA_PLAGE As String = "a2:j27"
'#################################################
Public ActivationRegle As Boolean
Dim OldRange As Range
Dim OldColor(1 To 10)
Sub Activer_Regle()
ActivationRegle = True
End Sub
Sub Desactiver_Regle()
ActivationRegle = False
Call RegleRepere
End Sub
Sub RegleRepere(Optional dummy As Byte)
Dim Plage As Range
Dim R As Range
Dim C As Range
Dim i&
If Not OldRange Is Nothing Then
For Each C In OldRange
i& = i& + 1
If OldColor(i&) <> "" Then
C.Interior.ColorIndex = OldColor(i&)
End If
Next C
End If
If Not ActivationRegle Then Exit Sub
Set R = Range(Selection.Address)
Set Plage = Range(MA_PLAGE)
Set R = Application.Intersect(R, Plage)
If Not R Is Nothing Then
Set R = Range(Cells(R.Row, Plage.Column), _
Cells(R.Row, Plage.Columns.Count + Plage.Column - 1))
i& = 0
Set OldRange = R
For Each C In R
i& = i& + 1
OldColor(i&) = C.Interior.ColorIndex
C.Interior.ColorIndex = 34
Next C
Else
Set OldRange = Nothing
End If
End Sub