Microsoft 365 Copier le contenu d'une colonne dans une autre colonne sous forme de commentaire

specialiste

XLDnaute Nouveau
Bonjour,
Je suis novice, et j'aimerais pouvoir copier le contenu d'une colonne (O) entière dans une autre colonne (P), mais en commentaire.
je suis parvenu à créer une macro, mais pour une seule cellule.
Voilà ce que j'ai pour l'instant.

Private Sub Worksheet_Activate()
With Range("P2")
If .Comment Is Nothing Then Range("P2").AddComment
.Comment.Text Text:=Sheets("Outlook Data").[O2].Value
.Comment.Shape.TextFrame.AutoSize = True

End With
End Sub

Merci de votre aide
Ben
 

job75

XLDnaute Barbatruc
Bonjour specialiste, bienvenue sur XLD,

Utilisez cette macro :
VB:
Private Sub Worksheet_Activate()
Dim r As Range
Application.ScreenUpdating = False
[P:P].ClearComments 'RAZ
With Sheets("Outlook Data")
    If .FilterMode Then .ShowAllData 'si la feuille est filtrée
    Set r = .Range("O2", .Range("O" & .Rows.Count).End(xlUp))
End With
If r.Row < 2 Then Exit Sub
For Each r In r
    If r <> "" Then
        With Range("P" & r.Row).AddComment
            .Text CStr(r)
            .Shape.TextFrame.AutoSize = True
        End With
    End If
Next
End Sub
Edit : ajouté If r.Row < 2 Then Exit Sub

A+
 
Dernière édition:

specialiste

XLDnaute Nouveau
Bonjour specialiste, bienvenue sur XLD,

Utilisez cette macro :
VB:
Private Sub Worksheet_Activate()
Dim r As Range
Application.ScreenUpdating = False
[P:P].ClearComments 'RAZ
With Sheets("Outlook Data")
    If .FilterMode Then .ShowAllData 'si la feuille est filtrée
    Set r = .Range("O2", .Range("O" & .Rows.Count).End(xlUp))
End With
If r.Row < 2 Then Exit Sub
For Each r In r
    If r <> "" Then
        With Range("P" & r.Row).AddComment
            .Text CStr(r)
            .Shape.TextFrame.AutoSize = True
        End With
    End If
Next
End Sub
Edit : ajouté If r.Row < 2 Then Exit Sub

A+
Bonjour specialiste, bienvenue sur XLD,

Utilisez cette macro :
VB:
Private Sub Worksheet_Activate()
Dim r As Range
Application.ScreenUpdating = False
[P:P].ClearComments 'RAZ
With Sheets("Outlook Data")
    If .FilterMode Then .ShowAllData 'si la feuille est filtrée
    Set r = .Range("O2", .Range("O" & .Rows.Count).End(xlUp))
End With
If r.Row < 2 Then Exit Sub
For Each r In r
    If r <> "" Then
        With Range("P" & r.Row).AddComment
            .Text CStr(r)
            .Shape.TextFrame.AutoSize = True
        End With
    End If
Next
End Sub
Edit : ajouté If r.Row < 2 Then Exit Sub

A+

Bonjour job75,
Mes remerciements sont tardifs, mais ils ne sont pas moins infinis!

Merci encore.
 

Discussions similaires

Statistiques des forums

Discussions
312 084
Messages
2 085 194
Membres
102 814
dernier inscrit
JLGalley