I have 2 sheet (Data sheet and RPT-1 sheet). When I click on RPT-1 sheet the filter is OK, then when I click the DATA sheet and then click RPT-1 again, the filter is not OK, but when I click DATA sheet and click RPT-1 for the second time, filter is OK. I have to go back in forth with the 2 sheets to activate the filter on RPT-1. The code below is what I’m working with but a revision is needed to work it. Hope that you guys can help me debug the code.
Thank you in advance.
Private Sub Worksheet_Activate()
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
Dim ws As Worksheet
Set ws = Sheets("RPT-1")
If Not Sheets("RPT-1").AutoFilterMode Then
ws.Unprotect Password:="."
ws.Range("A4:E4").AutoFilter
ws.Protect _
Contents:=True, _
AllowFiltering:=True, _
UserInterfaceOnly:=True, _
Password:="."
End If
With Application
.EnableEvents = True
.ScreenUpdating = True
End With
End Sub
Bookmarks