dleister
New Member
My objective is to have a button on the form which:
unprotects the form if it is protected
activates the autofilter for all columns if it is not already active
if it is already unprotected activates the autofilter for all columns if it is not already active
This code unfortunately does not operate the autofilter correctly; if the autofilter is already on it removes it
Here is my code:
unprotects the form if it is protected
activates the autofilter for all columns if it is not already active
if it is already unprotected activates the autofilter for all columns if it is not already active
This code unfortunately does not operate the autofilter correctly; if the autofilter is already on it removes it

Here is my code:
Code:
Sub FilterInv()
'
' FilterInv Macro for Invoice Log
'
With ActiveSheet
If ActiveSheet.ProtectContents = True Then
ActiveSheet.Unprotect
.AutoFilterMode = False
.Range("A6").AutoFilter
Else
.AutoFilterMode = False
.Range("A6").AutoFilter
End If
End With
End Sub
Last edited by a moderator: