Public Sub ProtectAllSheets()
Dim pWrd As Variant
Dim ws As Worksheet
'Ask the user for the password
pWrd = CStr(InputBox("Please enter the password to use", "Enter password"))
'Check what to do if password is blank or omitted
If Len(pWrd) = 0 Then
Select Case MsgBox("No password provided. Protect sheets with no password?", _
vbYesNoCancel, "I'm confused")
Case Is = vbNo, vbCancel
Exit Sub
Case Else
'User wants blank password
End Select
End If
'Protect the worksheets
For Each ws In ActiveWorkbook.Worksheets
ws.Protect Password:=pWrd
Next wsEnd Sub