I've created a button that the end user can press, in order to run a Macro, that will filter out a series of criteria, using the autofilter.
The code is below:
[VBA]Sub fjernsk?n()
Dim thissheet As String
Dim myrange As String
On Error GoTo Cancel
thissheet = ThisWorkbook.ActiveSheet.Name
myrange = ActiveCell.Address
Selection.AutoFilter Field:=4, Criteria1:="<>HUSK SK?N", Operator:=xlAnd _
, Criteria2:="<>HUSK LUK", Operator:=xlAnd _
, Criteria3:="<>KLAR TIL ARKIVERING"
Range("E3").Select
ActiveWindow.FreezePanes = False
ActiveWindow.FreezePanes = True
ActiveSheet.Range(myrange).Select
Cancel:
End Sub[/VBA]
The problem is that if one (or more) of the Criteria is missing (which could be possible) the code stops working.
How can I change this code so that it will filter out any/all of the occurances of the three listed criteria regardless of whether the criteria appears in the column or not?
Cheers