Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Solde, Lig, Col, Nom
Solde = 0
If Not Intersect(Target, Range("B2:B65356")) Is Nothing Then
Nom = Target.Value
Lig = Target.Row
Col = Range("IV1").End(xlToLeft).Column
For i = 2 To Lig
If Cells(i, 2) = Target Then
If Cells(i, 3) = "Report" Or Cells(i, 3) = "Val" Then
Solde = Solde + Cells(i, Col)
End If
End If
Next i
Solde = Format(Solde, "0.00")
ActiveSheet.UsedRange.ClearComments
If Target.Value <> "" Then
Target.AddComment.Text Text:="Solde de " & Nom & " :" & Chr(10) & Solde & " €"
With Target.Comment.Shape
.TextFrame.AutoSize = True
.OLEFormat.Object.Font.Bold = True
If Solde < 0 Then
.OLEFormat.Object.Font.ColorIndex = 3
Else
.OLEFormat.Object.Font.ColorIndex = xlAutomatic
End If
End With
End If
End If
End Sub