Salut
Dans l'évenement Workbook_Open , tu saisie le code suivente :
Private Sub Workbook_Open()
Protect_All
End Sub
Et dans un module tu saisie les deux codes suiventes :
- 1 ) Ce code pour protégé les feuilles
Sub Protect_All()
Application.DisplayAlerts = False
Dim Sh As Worksheet
For Each Sh In Sheets(Array("Source", "Données propres", "Données blablabla", "Logs", "Base Non Retenue"))
With Sh
.Select: .Protect ("xxx")
End With
Next
Application.DisplayAlerts = True
End Sub
- 2 ) Ce code pour trier les données dans la feuille nommé : "Source"
Sub Trier()
Application.DisplayAlerts = False
Dim Sh As Worksheet
Set Sh = Sheets("Source")
With Sh
.Unprotect ("xxx")
LR = .Cells(Rows.Count, 1).End(xlUp).Row
.Range("A2:H" & LR).Sort Key1:=.Range("A2"), Order1:=xlAscending 'xlDescending
.Protect ("xxx")
End With
Application.DisplayAlerts = True
End Sub