VBA Code :
Dim ws as Worksheet
Dim pwd as String
pwd = "" ' Put your password here
For Each ws In Worksheets
ws.Protect Password:=pwd
Next ws
Unprotecting is virtually the same:
Dim ws as Worksheet
Dim pwd as String
pwd = "" ' Put your password here
For Each ws In Worksheets
ws.Unprotect Password:=pwd
Next ws