XL 2010 Password VBA

lego35

XLDnaute Junior
Bonjour à tous

Ma macro fonctionne mais elle protège systématiquement la feuille... et dois systématiquement ôter la protection.
Un peu... nul en VBA, quelqu'un peut retirer le Password sans que cela bug.
Par avance merci
Lego

Macro (changement couleur cellule active) ci-dessous:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Set champ = Range("A1:FK550")
If Not Intersect(champ, Target) Is Nothing Then
ActiveSheet.Unprotect Password:=""
champ.FormatConditions.Delete
If Target.Count = 1 Then
Intersect(Target, champ).FormatConditions.Add Type:=xlExpression, Formula1:="VRAI"
Intersect(Target, champ).FormatConditions(1).Interior.ColorIndex = 8
Target.FormatConditions(1).Font.Bold = True
End If
ActiveSheet.Protect Password:=""
End If
End Sub
 

Si...

XLDnaute Barbatruc
Bonsoir

à essayer
VB:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim P As Range
    Set P = Range("A1:FK550")                                                'P lage à voir
    If Not Intersect(P, Target) Is Nothing Then
        Me.Unprotect
        P.FormatConditions.Delete
        If Target.Count = 1 Then
            Intersect(Target, P).FormatConditions.Add 2, , "VRAI"
            Intersect(Target, P).FormatConditions(1).Interior.ColorIndex = 8
            Target.FormatConditions(1).Font.Bold = 1
        End If
        Me.Protect
    End If
End Sub
 

Discussions similaires

Statistiques des forums

Discussions
312 100
Messages
2 085 294
Membres
102 854
dernier inscrit
ADRIENVR