I have a shared and protected worsheet in excel 2012. (protected but without password) I wrote this macro:
Private Sub CommandButton1_Click()
    ActiveSheet.Unprotect
    Range("B4:K38").Select
    Selection.Sort Key1:=Range("D4"), Order1:=xlAscending, Header:=xlGuess, _
        OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
        DataOption1:=xlSortNormal
   'cells I don't want to be protect (to be user-editable)
    Range("B4:K38").Locked = False
   'protecting the sheet, and all the other cells will be protected
    Protect UserInterfaceOnly:=True
End Sub
But everytime I use this macro I have a message that shows me that there's an error with the method protect.
What am I doing wrong?
 
     
    