XL 2016 protéger feuille en autorisant Tri et Filtre

  • Initiateur de la discussion Initiateur de la discussion KTM
  • Date de début Date de début

Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

KTM

XLDnaute Impliqué
Bonsoir chers tous
Je voudrais protéger ma base de données mais en autorisant le filtre et le tri.
Manuellement cela est possible pour moi mais je voudrais savoir comment le faire à l'aide d'une macro.
j'ai concocté un code à l'aide de l'éditeur de macro mais le coté filtre et tri ne marche pas.
Veuillez me donner un coup de pouce. Merci..

VB:
Sub Protect()
Application.ScreenUpdating = False
With Sheets("BASE")
.Unprotect (1234)
.EnableSelection = xlNoRestrictions
.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
        , AllowFormattingCells:=True, AllowFormattingColumns:=True, _
        AllowFormattingRows:=True, AllowSorting:=True, AllowFiltering:=True, _
        AllowUsingPivotTables:=True
.Protect (1234)
End With
End Sub
 

Pièces jointes

Bonjour,

Une proposition :
VB:
Sub Protect()
'
    Application.ScreenUpdating = False

    With Sheets("BASE")
        .Unprotect (1234)
        .EnableSelection = xlNoRestrictions
        .Protect Password:="1234", _
                DrawingObjects:=True, _
                Contents:=True, _
                Scenarios:=True, _
                AllowFormattingCells:=True, _
                AllowFormattingColumns:=True, _
                AllowFormattingRows:=True, _
                AllowSorting:=True, _
                AllowFiltering:=True, _
                AllowUsingPivotTables:=True
    End With

End Sub
 
Bonjour,

Une proposition :
VB:
Sub Protect()
'
    Application.ScreenUpdating = False

    With Sheets("BASE")
        .Unprotect (1234)
        .EnableSelection = xlNoRestrictions
        .Protect Password:="1234", _
                DrawingObjects:=True, _
                Contents:=True, _
                Scenarios:=True, _
                AllowFormattingCells:=True, _
                AllowFormattingColumns:=True, _
                AllowFormattingRows:=True, _
                AllowSorting:=True, _
                AllowFiltering:=True, _
                AllowUsingPivotTables:=True
    End With

End Sub
Merci pour tout!!
 
- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD

Discussions similaires

Réponses
17
Affichages
1 K
Réponses
2
Affichages
546
Réponses
2
Affichages
1 K
Réponses
4
Affichages
898
Retour