Hi i keep getting error 1004 when i try this, however it works sometimes and is very random, does exactly what i require but then sometimes the error comes up??

Would be grateful if anyone can offer any help

Here is the code anyway

Sub MAIN()


Dim wsWorksheet                 As Worksheet
 
    For Each wsWorksheet In ActiveWorkbook.Worksheets
        wsWorksheet.Unprotect Password:="changerecon"
        Cells.Select
        Selection.Locked = True
        wsWorksheet.Protect Password:="changerecon"
        
    Next
 
End Sub