Hello,
I have the following macro button in place to filter, and unfilter column 5 (table 1) for quantities greater than 1. I have added another column 6, which has a 1 or 0. The macro button to filter and unfilter column 5 must only apply to rows with a 1 in Column6.
I can't quite figure this out.
Thanks
Sub FilterTable()
Dim ws As Worksheet
Dim tbl As ListObject
Dim rng As Range
Set ws = ActiveSheet
Set tbl = ws.ListObjects("Table1")
If tbl.AutoFilter.FilterMode Then
tbl.AutoFilter.ShowAllData
Else
Set rng = tbl.ListColumns(5).DataBodyRange
rng.AutoFilter Field:=1, Criteria1:="<>", Operator:=xlAnd
End If
End Sub
I have the following macro button in place to filter, and unfilter column 5 (table 1) for quantities greater than 1. I have added another column 6, which has a 1 or 0. The macro button to filter and unfilter column 5 must only apply to rows with a 1 in Column6.
I can't quite figure this out.
Thanks
Sub FilterTable()
Dim ws As Worksheet
Dim tbl As ListObject
Dim rng As Range
Set ws = ActiveSheet
Set tbl = ws.ListObjects("Table1")
If tbl.AutoFilter.FilterMode Then
tbl.AutoFilter.ShowAllData
Else
Set rng = tbl.ListColumns(5).DataBodyRange
rng.AutoFilter Field:=1, Criteria1:="<>", Operator:=xlAnd
End If
End Sub