Hello

I have 4 worksheets, and when I want to open my workbook I want to protect them in a certain manner. I wrote the following sub that will protect any sheet I want when I call it and pass the sheet name to it:

Sub SetProtection(TargetSheet As Object)

    TargetSheet.Unprotect Password:=MyPassword

    TargetSheet.Range(UnlockedCell).Locked = False

    TargetSheet.Range(UnlockedCell).Select

    TargetSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:=MyPassword

    TargetSheet.EnableSelection = xlNoSelection

End Sub
Note: the variable UnlockedCell is a public string that has the value "A1".

So, when I call this sub, I do so like this:

SetProtection Sheet1
SetProtection Sheet2
SetProtection Sheet3
SetProtection Sheet4
The problem now is: The (SetProtection Sheet1) runs successfully, however, when it comes to run the second call (SetProtection Sheet2) it stops at the following line (TargetSheet.Range(UnlockedCell).Select) and gives me an error that says "run-time error 1004... the select method of the range class failed"

Someone might ask and say how I knew it referred to the 2nd call, and my answer is "I made a step-by-step debugging and that's where it stopped and gave me the error."

So does anyone know why and help me out with it plz