I am working on a spreadsheet to track maintenance, it needs to be protected so that none of the formulas or formats are messed up by the users.
Anyway I have this piece of Code that changes the sheet based on a a choice earlier on, and it runs perfectly when the sheet is protected or not:
And then I have this piece of code:
which is especially the same, but tells me the change is trying to be made on a protected sheet even though I have the unprotect line there.
Now I do realize that I have alterations to another sheet in that piece of code. However, I have tested it with the other sheet protected and unprotected and it makes no difference. I get the same error: "The cell or chart you're trying to change is on a protected sheet. To make a change, unprotect the sheet. You might be requested to enter a password."
Any help would be much appreciated.
Anyway I have this piece of Code that changes the sheet based on a a choice earlier on, and it runs perfectly when the sheet is protected or not:
Code:
If Target.Address = "$K$22" Then 'hides or unhides the appropriate columns for phase 1 or 3 power. ActiveSheet.Unprotect Password:="ex03740"
If Target.Value = "1" Then
Range("A25", "A27").EntireRow.Hidden = False
Range("A34", "A36").EntireRow.Hidden = False
Range("A28", "A32").EntireRow.Hidden = True
Range("A37", "A41").EntireRow.Hidden = True
Else
Range("A25", "A27").EntireRow.Hidden = True
Range("A34", "A36").EntireRow.Hidden = True
Range("A28", "A32").EntireRow.Hidden = False
Range("A37", "A41").EntireRow.Hidden = False
End If
ActiveSheet.Protect Password:="ex03740"
End If
And then I have this piece of code:
Code:
If Target.Address = "$U$42" Then 'hides or unhides the rows for battery dischrage test
ActiveSheet.Unprotect Password:="ex03740"
If Target.Value = "Yes" Then
ActiveSheet.Range("A48", "A50").EntireRow.Hidden = False
Sheets("Discharge Test").Visible = True
Else
ActiveSheet.Range("A48", "A50").EntireRow.Hidden = True
Sheets("Discharge Test").Visible = False
End If
ActiveSheet.Protect Password:="ex03740"
End If
which is especially the same, but tells me the change is trying to be made on a protected sheet even though I have the unprotect line there.
Now I do realize that I have alterations to another sheet in that piece of code. However, I have tested it with the other sheet protected and unprotected and it makes no difference. I get the same error: "The cell or chart you're trying to change is on a protected sheet. To make a change, unprotect the sheet. You might be requested to enter a password."
Any help would be much appreciated.