Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
Rows(2).ClearComments 'Effacer commentaires ligne 2
Rows(2).Interior.ColorIndex = 0 'Effacer couleurs ligne 2
Columns(2).ClearComments 'Effacer commentaires colonne 2
Columns(2).Interior.ColorIndex = 0 'Effacer couleurs colonne 2
[E4:O25].Interior.ColorIndex = 0 'Effacer couleurs cadre
If Not Intersect(Target, Range("E4:O25")) Is Nothing Then
Application.ScreenUpdating = False
' Highlight the entire row and column that contain the active cell
Range(Cells(Target.Row, 5), Cells(Target.Row, Target.Column)).Interior.ColorIndex = 8
Range(Cells(4, Target.Column), Cells(Target.Row, Target.Column)).Interior.ColorIndex = 8
' Highlight the cells of Col B & Line 2
Set_Comment Cells(2, Target.Column)
Set_Comment Cells(Target.Row, 2)
End If
End Sub
Sub Set_Comment(Cell As Range)
Cell.Interior.Color = RGB(255, 100, 255) ' Couleur cellule
With Cell.AddComment(Cell.Text).Shape
.TextFrame.HorizontalAlignment = xlCenter ' Alignement horizontal du commentaire
.TextFrame.VerticalAlignment = xlCenter ' Alignement vertical du commentaire
.Fill.ForeColor.RGB = RGB(255, 100, 255) ' Couleur de fond du commentaire
.DrawingObject.Font.Name = "Tahoma" ' Nom de la Police utilisée
.DrawingObject.Font.Bold = True ' Police en Gras
.DrawingObject.Font.Size = 14 ' Taille Police
.Visible = msoTrue ' Pour forcer l'affichage du commentaire
End With
End Sub