Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Limiter à 4 cellules
If Intersect(Target, [C3]) Is Nothing And _
Intersect(Target, [C5]) Is Nothing And _
Intersect(Target, [F3]) Is Nothing And _
Intersect(Target, [F5]) Is Nothing Then
Exit Sub
End If
'RAZ
Dim lesautres As Range
Set lesautres = Application.Union([B3], [B5], [E3], [E5])
With lesautres
.Value = "UX/1UY"
.Interior.Color = 3899904 'vert
.Font.Color = 49407 'orange
.HorizontalAlignment = xlCenter
End With
Application.Union([C3], [C5], [F3], [F5]).Interior.Color = 13434879 'jaune pâle
'cellule cliquée
With Target.Offset(0, -1)
.Value = "UX/1UY désiré"
.Interior.Color = 6634265 'bleu
.Font.Color = 65535 'jaune
.HorizontalAlignment = xlLeft
End With
Target.Interior.Color = 16777215 'blanc
End Sub
If Intersect(Target, [C3]) Is Nothing And _
Intersect(Target, [C5]) Is Nothing And _
Intersect(Target, [F3]) Is Nothing And _
Intersect(Target, [F5]) Is Nothing Then
Exit Sub
End If
If Intersect(Target, Union([C3], [C5], [F3], [F5])) Is Nothing Then Exit Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim r As Range
Set r = [C3,C5,F3,F5]
r.Interior.Color = 13434879 'jaune pâle
With r.Offset(, -1)
.Value = "UX/1UY"
.Interior.Color = 3899904 'vert
.Font.Color = 49407 'orange
.HorizontalAlignment = xlCenter
End With
If Intersect(Target, r) Is Nothing Then Exit Sub
For Each r In r
If Not Intersect(Target, r) Is Nothing Then
r.Interior.Color = 16777215 'blanc
With r(1, 0)
.Value = "UX/1UY désiré"
.Interior.Color = 6634265 'bleu
.Font.Color = 65535 'jaune
.HorizontalAlignment = xlLeft
End With
End If
Next
End Sub