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 43 44 45 46 47 48 49 50 51 52
| Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim cellCarte As Range
Dim site As String
Dim correspondance As Object
Dim adresseCellule As String
' Vérifie si la sélection est dans la plage B3:B22
If Not Intersect(Target, Me.Range("B3:B22")) Is Nothing Then
' Création du dictionnaire de correspondance
Set correspondance = CreateObject("Scripting.Dictionary")
' Efface les mises en forme précédentes
Me.Cells.Interior.ColorIndex = xlNone
Me.Cells.Font.Bold = False
' Remplissage du dictionnaire avec les paires B -> Cellule correspondante
correspondance.Add "B3", "L6"
correspondance.Add "B4", "V23"
correspondance.Add "B5", "AC12"
correspondance.Add "B6", "M18"
correspondance.Add "B7", "L15"
correspondance.Add "B8", "I10"
correspondance.Add "B9", "T2"
correspondance.Add "B10", "L12"
correspondance.Add "B11", "Q2"
correspondance.Add "B12", "AD10"
correspondance.Add "B13", "I7"
correspondance.Add "B14", "AB19"
correspondance.Add "B15", "Y5"
correspondance.Add "B16", "Z22"
correspondance.Add "B17", "AA13"
correspondance.Add "B18", "W3"
correspondance.Add "B19", "AB8"
correspondance.Add "B20", "M22"
correspondance.Add "B21", "O5"
correspondance.Add "B22", "AB16"
' Récupère la cellule cible dans le dictionnaire
If correspondance.exists(Target.Address(False, False)) Then
adresseCellule = correspondance(Target.Address(False, False))
' Applique la mise en forme à la cellule correspondante
Set cellCarte = Me.Range(adresseCellule)
cellCarte.Interior.Color = RGB(255, 255, 0) ' Jaune
cellCarte.Font.Bold = True
End If
' Nettoyage du dictionnaire
Set correspondance = Nothing
End If
End Sub |
Partager