It depends if you're trying to run it on demand for a specific worksheet, or if you want to do all worksheets in the workbook.
If you want to re-protect all worksheets at open, and make sure userinterfaceonly is set to true as well, then you'd drop this in the ThisWorkbook module:
Code:
Private Sub Workbook_Open()
Dim pWord As String
Dim ws As Worksheet
'Set your password here
pWord = "myPassword"
'Re-protect all sheets
For Each ws In ThisWorkbook.Worksheets
ws.Protect Password:=pWord, userinterfaceonly:=True
Next ws
End Sub
If you want to do a single worksheet, then you'd use code like this in whatever routine you decide needs it:
Code:
Worksheets("Sheet_x").Protect Password:="myPassword", UserInterfaceOnly:=True
Of course you'd need to update the password and the name of the worksheet.
Does that make more sense?
Bookmarks