Modification de macro transformant une colonne en commentaire

Tohane

XLDnaute Nouveau
Bonjour,
En surfant sur le net j'ai decouvert une macro permettant de transformer une colonne en commentaire, or m'y connaissant pas trop je voudrais rajouter un tit parametre à celle ci, je souhaiterais que dans la colonne que je selectionne, tout soi transformé en commentaire SAUF les cellule où il y a ecri "None".

Si quelqu'un pouvait m'aider.. Merci !

'
Dim c As Range
Dim Moi As String
' ************************
Moi = "SOF" ' À renseigner avec ses initiales
' ************************
For Each c In Selection
With c
If .Comment Is Nothing Then ' Le commentaire n'existe pas, on le crée
.AddComment
.Comment.Visible = False
.Comment.Text Text:=Moi & " (" & Date & ") :" & Chr(10) & "Contract = " & c.Value
.ClearContents
Else ' Un commentaire existe déjà, on ajoute alors le nouveau à la fin de celui existant
.Comment.Text Text:=.Comment.Text & _
Chr(10) & Moi & " (" & Date & ") :" & _
Chr(10) & "Contract = " & c.Value
End If
End With
Next c
End Sub
 

SergiO

XLDnaute Accro
Re : Modification de macro transformant une colonne en commentaire

Bonjour Tohane,


Rajoute ce qui est en rouge:
Code:
Dim c As Range
Dim Moi As String
' ************************
Moi = "SOF" ' À renseigner avec ses initiales
' ************************
For Each c In Selection
With c
[COLOR=Red]If . value <> "None Then[/COLOR]
If .Comment Is Nothing Then ' Le commentaire n'existe pas, on le crée
.AddComment
.Comment.Visible = False
.Comment.Text Text:=Moi & " (" & Date & ") :" & Chr(10) & "Contract = " & c.Value
.ClearContents
Else ' Un commentaire existe déjà, on ajoute alors le nouveau à la fin de celui existant
.Comment.Text Text:=.Comment.Text & _
Chr(10) & Moi & " (" & Date & ") :" & _
Chr(10) & "Contract = " & c.Value
End If
[COLOR=Red]End if[/COLOR]
End With
Next c
End Sub
@+
 

Discussions similaires

Statistiques des forums

Discussions
312 168
Messages
2 085 907
Membres
103 029
dernier inscrit
ndembi sylver