Hello, The following code (without the unprotect bit) does exactly as it is meant to do, and sorts the rows when then date changes in column H, but not when the sheet is protected.
I have tried to adapt the code to unprotect and then protect again afterwards but it isn't working. Could someone point me in the right direction and explain what I have or haven't done correctly
Thanks
Private Sub Worksheet_Change(ByVal Target As Range)
Dim LRow As Long
Dim TheList As Range
Dim Pwd As String
Pwd = "123"
On Error GoTo errorhandler
Sheet11.Unprotect Password:=Pwd
LRow = Cells(Rows.Count, "H").End(xlUp).Row
Set TheList = Range("B4:AC15")
On Error Resume Next
TheList.Sort Key1:=Range("H4"), Order1:=xlAscending
End If
Sheet11.Protect Password:=Pwd
Exit Sub
errorhandler: MsgBox "wrong password"
Exit Sub
End Sub
Bookmarks