Private Sub Workbook_Open() ActiveSheet.Unprotect Password:="0000" Worksheets("Feuil1").Cells.Locked = False Worksheets("Feuil1").Cells.SpecialCells(xlCellTypeConstants).Locked = True Worksheets("Feuil1").Protect Password:="0000" End Sub
Private Sub Workbook_Open() ActiveSheet.Unprotect Password:="0000" Worksheets("Feuil1").Cells.Locked = False If Not IsEmpty(Worksheets("Feuil1").Cells.SpecialCells(xlCellTypeLastCell)) Then Worksheets("Feuil1").Cells.SpecialCells(xlCellTypeConstants).Locked = True End If Worksheets("Feuil1").Protect Password:="0000" End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionPrivate Sub Worksheet_Change(ByVal Target As Range) ' donc à chaque fois que tu change la valeur d'une cellule ActiveSheet.Unprotect Password:="0000" ' tu déprotège ===>> OK Target.Locked True ' tu bloques une cellule>> OK mauis quid des autres ? elles ne sont pas déverrouillées ! Selection.Rows.AutoFit ActiveSheet.Protect Password:="0000" ' tu reprotèges ===>> OK, mais comment vas-tu maintenant 'pouvoir modifier une cellule ? (Or tu as choisi cet évènement pour déprotéger ! End Sub
ActiveSheet.Unprotect Password:="0000" Cells.Locked = False
Private Sub Worksheet_Activate() ActiveSheet.Unprotect Password:="0000" Cells.Locked = False Cells.SpecialCells(xlCellTypeConstants).Locked = True ActiveSheet.Protect Password:="0000" End Sub Private Sub Worksheet_Change(ByVal Target As Range) ActiveSheet.Unprotect Password:="0000" Target.Locked = True Selection.Rows.AutoFit ActiveSheet.Protect Password:="0000" End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean) ActiveSheet.Unprotect Password:="0000" Sheets("Feuil1").Cells.Locked = True ActiveSheet.Protect Password:="0000" End Sub
j'ai oublié de preciser macro active ou non