Run VBA code at protected and shared workbook

Posts
1
Registration date
Thursday January 10, 2019
Last seen
January 10, 2019
-
Hi,
I have the code like below, I want to use protected and shared workbook. but the code doesn't work. What should am I do?

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column <> 11 Or Target.Columns.Count > 1 Then _
If Target.Column <> 13 Or Target.Columns.Count > 1 Then _
If Target.Column <> 18 Or Target.Columns.Count > 1 Then _
Exit Sub
Dim tmp As Variant
tmp = Cells(Target.row, 18).Formula 'save contents
On Error GoTo Enable_Events
Application.EnableEvents = False
Cells(Target.row, 18) = "#$"
Range("K1").Sort Key1:=Range("K1"), Order1:=xlAscending, Header:=xlYes
Cells(Application.Match("#$", Columns(18), 0), 11).Select
Range("M1").Sort Key1:=Range("M1"), Order1:=xlAscending, Header:=xlYes
Cells(Application.Match("#$", Columns(18), 0), 13).Select
Range("R1").Sort Key1:=Range("R1"), Order1:=xlDescending, Header:=xlYes
Cells(Application.Match("#$", Columns(18), 0), 18).Select
Cells(Selection.row, 18) = tmp 'restore contents
Enable_Events:
Application.EnableEvents = True
End Sub
See more