Afficher un commentaire en auto

Bonjour la Compagnie ...

Comment peut-on afficher dans une cellule un commentaire dynamique ? soit par fonction, soit par VBA ?

Merciiiiiiiiiiii


Je pense que j'ai posé la question trop vite, j'ai une réponse partielle ici :

                If Target.Comment Is Nothing Then
                    'On ajoute un commentaire s'il n'existe pas
                    Target.AddComment Text:="" & "bla bla"
                Else
                    'On modifie le commentaire existant
                    Target.Comment.Text Text:="" & "bla bla"
                End If

Salut Steelson,

Bonne année 2017!

Je n'aurais pas mieux dit!

A+

Bonjour Steelson, curulis57,

À tester:

Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Count > 1 Then Exit Sub
    If Target.Address <> "$E$11" Then Exit Sub
    On Error Resume Next
    Target.Offset(0, 1).Comment.Delete
    lig = Application.Match(Target, [A:A], 0)
    If Target <> "" Then Target.Offset(0, 1).AddComment Cells(lig, 3).Value
End Sub

Le commentaire sera modifié à chaque changement de valeur en E11. Il reste peut-être l'un ou l'autre test à ajouter.

Bonjour Steelson,

J'ai un fichier où j'utilise la fonction comme ceci:

For i =1 to NbBoucles
      sheets("Feuil1").cells(Ligne, colonne).AddComment CStr(LC(i, 1))
Next i

LC(i,1) où LC est un tableau à une dimension.

Cordialement

Merci de vos inputs

Plus simple que je croyais !

Function commenter(cel As Range) As String
Dim Cherche As Range

commenter = ""
If Not (Application.Caller.Comment) Is Nothing Then Application.Caller.ClearComments

With Sheets("Feuil1").ListObjects("Tableau1")
    Set Cherche = .ListColumns("Code").Range.Find(cel, SearchDirection:=xlNext)
    If Cherche Is Nothing Then Exit Function
    i = Cherche.Row - .HeaderRowRange.Row
    commenter = .ListColumns("Nom").DataBodyRange.Rows(i).Value
    If (Application.Caller.Comment) Is Nothing Then Application.Caller.AddComment
    Application.Caller.Comment.Text .ListColumns("Commentaire").DataBodyRange.Rows(i).Value
End With

End Function
Rechercher des sujets similaires à "afficher commentaire auto"