Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Simple workbook Protect
morning,
could some-one please give me a very simple code for unprotecting and then reprotecting an entire workbook (it contains three sheets)? I am looking for a code to replace the protect sheet version of Sheets("UP4 Données").Unprotect Password:="ABCDEFGH" to the workbook version. I have other code driven by macro buttons which I will put in between the unprotect and protect codes just for reference. Thanks LiAD |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Simple workbook Protect
Sub ProtectAllSheets()
For Each Shts In ThisWorkbook.Worksheets Shts.Protect Password:="ABCDEFGH" Next End Sub If this post helps click Yes --------------- Jacob Skaria "LiAD" wrote: morning, could some-one please give me a very simple code for unprotecting and then reprotecting an entire workbook (it contains three sheets)? I am looking for a code to replace the protect sheet version of Sheets("UP4 Données").Unprotect Password:="ABCDEFGH" to the workbook version. I have other code driven by macro buttons which I will put in between the unprotect and protect codes just for reference. Thanks LiAD |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Simple workbook Protect
Hi,
Thanks for your help again. I have pasted the protect macro into a save maro and also a calculation macro. It works well with the save one but not with the calculation one. Would you know why? The line it points to as faulting is - Range("J38").Value = Range("J38").Value - 1 The full macro is below. Thankyou Sub UtiliséBobine15() For Each Shts In ThisWorkbook.Worksheets Shts.Unprotect Password:="ABCDEFG" Next Call AddToLog("UtiliséBobine15") With Sheet1 ' Changer to suit If Range("J38").Value < "" Then ' Change J38 to suit Range("J38").Value = Range("J38").Value - 1 End If End With For Each Shts In ThisWorkbook.Worksheets Shts.Protect Password:="ABCDEFG" Next End Sub Sub AddToLog(MacName As String) For Each Shts In ThisWorkbook.Worksheets Shts.Unprotect Password:="ABCDEFG" Next Dim NextRow As Long With Worksheets("Log") NextRow = .Cells(.Rows.Count, "A").End(xlUp).Row + 1 .Cells(NextRow, "A").Value = MacName .Cells(NextRow, "B").Value = Now End With For Each Shts In ThisWorkbook.Worksheets Shts.Protect Password:="ABCDEFG" Next End Sub "Jacob Skaria" wrote: Sub ProtectAllSheets() For Each Shts In ThisWorkbook.Worksheets Shts.Protect Password:="ABCDEFGH" Next End Sub If this post helps click Yes --------------- Jacob Skaria "LiAD" wrote: morning, could some-one please give me a very simple code for unprotecting and then reprotecting an entire workbook (it contains three sheets)? I am looking for a code to replace the protect sheet version of Sheets("UP4 Données").Unprotect Password:="ABCDEFGH" to the workbook version. I have other code driven by macro buttons which I will put in between the unprotect and protect codes just for reference. Thanks LiAD |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Can protect worksheet then workbook but not Protect and Share in code | Excel Programming | |||
Urgent - Simple Workbook Protect | Excel Discussion (Misc queries) | |||
Protect Workbook Vs Protect Sheet | New Users to Excel | |||
Disable Tools, Protect, Protect Workbook | Excel Programming | |||
Running a macro to protect a workbook on a already protected workbook UNprotects the workbook ?? | Excel Programming |