Maybe like this
Code:Sub MM1() Dim ws As Worksheet For Each ws In Worksheets ws.Protect "password" Next ws End Sub
Sub MM1()
Dim pwd As String
pwd = InputBox("Please Enter the password")
If pwd = "" Then Exit Sub
ActiveWorkbook.Protect Structure:=True, Windows:=True, Password:=pwd
MsgBox "Workbook is now locked."
End Sub
Sorry....I thought locking the sheets may have been adequate...
Try
Code:Sub MM1() Dim pwd As String pwd = InputBox("Please Enter the password") If pwd = "" Then Exit Sub ActiveWorkbook.Protect Structure:=True, Windows:=True, Password:=pwd MsgBox "Workbook is now locked." End Sub
Sub MM1()
Dim ws As Worksheet
For Each ws In Worksheets
ws.Protect "password"
Next ws
End Sub
Sub MM1()
Dim pwd As String
pwd = InputBox("Please Enter the password")
If pwd = "" Then Exit Sub
ActiveSheet.Unprotect Password:=pwd
MsgBox "Worksheet is now open."
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim ws As Worksheet
For Each ws In Worksheets
ws.Protect "password"
Next ws
End Sub