I reformatted my code so
Private Sub CommandButton2_Click()
'Show all (Remove filter)
Worksheets("LogIn").Protect "testing", True, True, True, userinterfaceonly:=True
If ActiveSheet.FilterMode = False Then
ActiveSheet.AutoFilterMode = False
Exit Sub
End If
ActiveSheet.ShowAllData
ActiveSheet.AutoFilterMode = False
Range("A5").Select 'to position active cell
End Sub
This works if
1) I have no filters running
2) I have the advance filter running
When there's an autofilter, it gets to this line and gives this error
ActiveSheet.AutoFilterMode = False (the 2nd one)
Runtime error 1004
"Unable to set the autofiltermode property of the worksheet class"
Bookmarks