Extraire le texte d'une cellule pour en faire commentaire d'une autre

10classeur1.xlsx (10.80 Ko)

Bonjour,

je voudrais comme dans l'exemple ci joint pouvoir extraire le contenue d'une cellule (feuille 2 > b3:B9) et les insérer en tant que commentaire dans la feuille 1> D4:d10)

je l'ai fait manuellement pour comprendre ma demande, mais je voudrais pouvoir le faire d'une manière automatique et que si je modifie quelques choses dans la feuille 2, ça se mette a jour automatiquement

Merci pour votre aide

Bonjour,

Si j'ai bien compris, voici votre fichier avec le résultat espéré :

13classeur1-1.xlsm (18.90 Ko)

Cdlt,

Bonjour,

c'est exactement ça !!

comment faire si je veux avoir une ou deux autres feuilles comme (feuil1) qui recevrait aussi les infos bulles venant de (feuil2) ?

Merci

Bonjour,

Si la plage de base est toujours la même (f2!B3:B9), il suffit de rajouter des lignes :

Private Sub Worksheet_Change(ByVal Target As Range)

Dim r As Range
Set r = Intersect(Target, Range("B3:B9"))

If Not r Is Nothing Then
    For Each cell In r
        comm = r.Value
        ligne = cell.Row - Range("B3:B9").Row + 1
        With Sheets("Feuil1").Range("D4:D10")(ligne) '<<<< POUR L'INSTANT
            If Not .Comment Is Nothing Then .Comment.Delete
            If cell.Value <> "" Then .AddComment Text:=comm
        End With
        With Sheets("TOTO").Range("A1:A7")(ligne)
            If Not .Comment Is Nothing Then .Comment.Delete
            If cell.Value <> "" Then .AddComment Text:=comm
        End With
        With Sheets("TUTU").Range("Z11:Z17")(ligne)
            If Not .Comment Is Nothing Then .Comment.Delete
            If cell.Value <> "" Then .AddComment Text:=comm
        End With
    Next
End If

End Sub

Il faut juste que les plages soient à chaque fois de même dimension pour que ça marche correctement.

Cdlt,

merci c'est tout a fait ça

une derniere question ?

comment faire pour prendre une autre plage par exemple D3:D9 cette fois ci ?

suis-je obliger de refaire un autre pavé ? ou je peux juste ajouter au sein de celui la comme pour l'ajout

Merci

Tout dépend du résultat désiré... Si les plages sont discontinues sans lien tangible, alors il faudrait plutôt faire quelque chose comme ça :

Private Sub Worksheet_Change(ByVal Target As Range)

Dim r As Range, r2 as range
Set r = Intersect(Target, Range("B3:B9"))
set r2 = Intersect(Target, Range("X1:X7")) 'exemple

If Not r Is Nothing Then
    For Each cell In r
        comm = r.Value
        ligne = cell.Row - Range("B3:B9").Row + 1
        With Sheets("Feuil1").Range("D4:D10")(ligne) '<<<< POUR L'INSTANT
            If Not .Comment Is Nothing Then .Comment.Delete
            If cell.Value <> "" Then .AddComment Text:=comm
        End With
        With Sheets("TOTO").Range("A1:A7")(ligne)
            If Not .Comment Is Nothing Then .Comment.Delete
            If cell.Value <> "" Then .AddComment Text:=comm
        End With
    Next
End If

If Not r2 Is Nothing Then
    For Each cell In r2
        comm = r2.Value
        ligne = cell.Row - Range("X1:X7").Row + 1
        With Sheets("Feuil1").Range("zdazaz")(ligne) '<<<< POUR L'INSTANT
            If Not .Comment Is Nothing Then .Comment.Delete
            If cell.Value <> "" Then .AddComment Text:=comm
        End With
        With Sheets("TOTO").Range("zazaeff")(ligne)
            If Not .Comment Is Nothing Then .Comment.Delete
            If cell.Value <> "" Then .AddComment Text:=comm
        End With
    Next
End If

End Sub

Mais attention à pas s'emmêler les pinceaux sachant que le but n'est pas d'avoir un pavé de code sous cet évènement.

Sinon, il vaudrait mieux reformuler clairement le besoin car il doit être possible de factoriser tout ça...

Cdlt,

ok je vais tester ça,

je te remercie énormément pour ton aide

Cordialement

Rechercher des sujets similaires à "extraire texte commentaire"