reporter les commentaires

noon

XLDnaute Junior
bonjour
quand j'insere un commentaire dans une cellule j'aimerais que ce commentaire soit renvoyé dans une cellule ou tout mes commentaires de différentes autres cellules se retrouve

merci
 

Gorfael

XLDnaute Barbatruc
Re : reporter les commentaires

noon à dit:
bonjour
quand j'insere un commentaire dans une cellule j'aimerais que ce commentaire soit renvoyé dans une cellule ou tout mes commentaires de différentes autres cellules se retrouve

merci
Salut et bonne année
dans le module de la feuille concernée :
en tête du module :
Code:
Option Explicit
Dim Target_1 As Range
Dim Txt_Comment As String
ces deux variables seront utilisées pour stocker les infos lors de la sélection d'une cellule. Elles sont nécessaires aux 2 variantes
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim C
Dim Str_Comm As String
If Not (Target_1 Is Nothing) Then
    If Target_1.Comment Is Nothing Then
        If Txt_Comment <> "" Then GoTo MAJ_Comm
    Else
        If Target_1.Comment.Text <> Txt_Comment Then GoTo MAJ_Comm
    End If
End If
Memorisation:
Set Target_1 = Target
If Target_1.Comment Is Nothing Then
    Txt_Comment = ""
Else
    Txt_Comment = Target_1.Comment.Text
End If
Exit Sub
MAJ_Comm:
For Each C In ActiveSheet.Comments
    Str_Comm = IIf(Str_Comm = "", C.Text, Str_Comm & Chr(10) & Chr(10) & C.Text)
Next C
Range("A1") = Str_Comm
GoTo Memorisation
End Sub
ou variante avec adresse cellule
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim C
Dim Str_Comm As String
If Not (Target_1 Is Nothing) Then
    If Target_1.Comment Is Nothing Then
        If Txt_Comment <> "" Then GoTo MAJ_Comm
    Else
        If Target_1.Comment.Text <> Txt_Comment Then GoTo MAJ_Comm
    End If
End If
Memorisation:
Set Target_1 = Target
If Target_1.Comment Is Nothing Then
    Txt_Comment = ""
Else
    Txt_Comment = Target_1.Comment.Text
End If
Exit Sub
MAJ_Comm:
For Each C In ActiveSheet.Comments
    If Str_Comm <> "" Then Str_Comm = Str_Comm & Chr(10) & Chr(10)
    Str_Comm = Str_Comm & C.Parent.Address(0, 0) & Chr(10) & C.Text
Next C
Range("A1") = Str_Comm
GoTo Memorisation
End Sub
A+
 
Dernière édition: