I am trying to save the sheet with password but I am not able to unlock it with same password, can someone please help me out with getting this resolved.
Sub ClearData()
ActiveSheet.Unprotect Password = "Kiran123"
Sheets("Filter").Select
Range("A11").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Clear
Sheets("Filter").Select
Range("C3").Select
Selection.Clear
ActiveSheet.Protect Password = "Kiran123"
End Sub
Thanks for checking this, However when I have tried with above code(my code) it doesn't work. However when you try it with only below sub it works, why such ambiguity in both the codes. any specific reason why this is occurring ? would be great if I can get an code to lock the sheet with password.
Sub test()
ActiveSheet.Protect Password:="Kiran123"
ActiveSheet.Unprotect Password:="Kiran123"
End Sub
On Error Resume Nextanywhere in your code? As @Eirikdaude's answer mentions your code shouldn't compile, much less run and this is the only reason I can think of that would cause this.