Bonjour,
A tester si ça convient :
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim WF As WorksheetFunction
Dim F As Worksheet
Dim test
Dim Plage As Range
Dim Cel As Range
Dim Chaine As String
Dim Adr As String
Range("B4:AP53").ClearComments
Set WF = WorksheetFunction
With Worksheets("Stocks"): Set Plage = .Range(.Cells(4, 3), .Cells(.Rows.Count, 3).End(xlUp)): End With
On Error Resume Next
test = WF.Match(Target, Plage, 0)
If Err.Number <> 0 Then Exit Sub
If Target.Value = "" Then Exit Sub
If Intersect(Target, Range("B4:AP53")) Is Nothing Then Exit Sub
Set Cel = Plage.Find(Target.Value, , xlValues, xlWhole)
If Not Cel Is Nothing Then
Adr = Cel.Address
Chaine = Cel.Offset(, -1).Value & vbCrLf
Chaine = Chaine & "Qté = " & WF.SumIf(Plage, Target, Plage.Offset(, 5)) & vbCrLf
Do
Chaine = Chaine & Cel.Offset(, 2).Value & " = " & Cel.Offset(, 5).Value & vbCrLf
Set Cel = Plage.FindNext(Cel)
Loop While Adr <> Cel.Address
End If
Chaine = Left(Chaine, Len(Chaine) - 1)
With Target
.AddComment
.Comment.Visible = True
.Comment.Text Chaine
.Comment.Shape.TextFrame.Characters(1, Len(Split(Chaine, vbCrLf)(0))).Font.Bold = True
.Comment.Shape.TextFrame.AutoSize = True
End With
End Sub