I can’t seem to make this work. It is supposed to unlock the sheet, change the row status and lock back with the same PW.
Any ideas what might be wrong? I’m very new to VBA and this code is made using AI.
Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$M$10" Then
If Target.Value > 0 Then
If ActiveSheet.ProtectContents Then
ActiveSheet.Unprotect Password:="TL1234"
Rows("18:20").EntireRow.Hidden = False
ActiveSheet.Protect Password:="TL1234"
End If
Else
If ActiveSheet.ProtectContents Then
ActiveSheet.Unprotect Password:="TL1234"
Rows("18:20").EntireRow.Hidden = True
ActiveSheet.Protect Password:="TL1234"
End If
End If
End If
End Sub
Rows image
I’ve tried with and without the “Activesheet”-lines to make it simpler, couldn’t quite make that work either, even though it worked previously…
New contributor
jonathan Jonfan brandstrup is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.