Option Explicit
Sub test()
Dim t As String, c As Range
t = InputBox("Mot de passe ??")
On Error Resume Next
Set c = Application.InputBox("plage dfe cellule non protégée...", Type:=8)
If Err.Number <> 0 Or t = "" Then Exit Sub
On Error GoTo 0
c.Locked = False
ActiveSheet.Protect t
End Sub