Protection macro

RVL

XLDnaute Occasionnel
Bonjour à tous,

J'ai rélalisé recemment un fichier comportant des macros et ce avec l'aide de pls membres du forum que je remercie encore.

Ne comprenant tjs pas vraiment le VBA, j'aimerai savoir comment faire pour modifier la macro suivante afin que je puisse insérer un commentaire aux cellules:("D1:D2,F1:F2,C7:K12,D14:D15,F14:F15,C20:G25,D27:D28,F27:F28,C33:L39,D41:D42,F41:F42,C47:J53,I19:I23,I25:I28,K19:L26,K45:L45,J42:L42,L49:L53,N3:N41") et que ce commentaire reste aprés la macro tranfert de "f1" vers "f2".

Sheets("f1").Unprotect "toto"
Sheets("f2").Unprotect "toto"
Dim plage As Range, c As Range, cSource As Range
Set plage = Feuil1.Range("D1:D2,F1:F2,C7:K12,D14:D15,F14:F15,C20:G25,D27:D28,F27:F28,C33:L39,D41:D42,F41:F42,C47:J53,I19:I23,I25:I28,K19:L26,K45:L45,J42:L42,L49:L53,N3:N41")
Application.ScreenUpdating = False
For Each c In plage
If Not IsEmpty(c) Then 'And Not c.Locked
Set cSource = Sheets("f3").UsedRange.Find(what:=c, LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=False)
If Not cSource Is Nothing Then
If cSource.Offset(0, 8).Value = "B" Then
c.Copy Destination:=Sheets("f2").Range(c.Address)
c.Clear 'Nettoie la cellule, contenu et format.
c.Locked = False
End If
End If
End If
Next c
Application.ScreenUpdating = True
Sheets("f1").Protect "toto", AllowFormattingCells:=True
Sheets("f2").Protect "toto", AllowFormattingCells:=True
End Sub

En ésperant avoir été "claire "
 

Statistiques des forums

Discussions
312 169
Messages
2 085 921
Membres
103 039
dernier inscrit
SoulMat69