Hi,
Im trying to filter multiple tables by a common table header cell called "Match:". If the row in any table on the worksheet in column "Match:" is True, then show that row with the table that it is in, otherwise i want the entire table hidden including the first row right above the table. I have pieced together some code that works pretty good, except the looping (going to next table) seems to not be working properly. It hides all the tables properly until it finds a table that has "True" in the "Match:" column, then this code doesnt continue on to any tables that are below this one. Can anyone help out to see what i need to put in this code so that it continues on to the next table after it hides/or doesn't hide them depending on the value in the "Match:" field? See current code below:
Im trying to filter multiple tables by a common table header cell called "Match:". If the row in any table on the worksheet in column "Match:" is True, then show that row with the table that it is in, otherwise i want the entire table hidden including the first row right above the table. I have pieced together some code that works pretty good, except the looping (going to next table) seems to not be working properly. It hides all the tables properly until it finds a table that has "True" in the "Match:" column, then this code doesnt continue on to any tables that are below this one. Can anyone help out to see what i need to put in this code so that it continues on to the next table after it hides/or doesn't hide them depending on the value in the "Match:" field? See current code below:
Code:
Sub FilterAllTables()
Cells.EntireRow.Hidden = False
Dim Tbl As ListObject, Fld As Integer, tCount As Integer, tRng As Range
For Each Tbl In ActiveSheet.ListObjects
Fld = WorksheetFunction.Match("Match:", Tbl.HeaderRowRange, 0)
Tbl.AutoFilter.ShowAllData
Tbl.Range.AutoFilter Field:=Fld, Criteria1:="TRUE"
On Error Resume Next
Set tRng = Tbl.HeaderRowRange.Offset(-1).Resize(2)
tCount = Tbl.DataBodyRange.SpecialCells(xlCellTypeVisible).Count
If tCount = 0 Then tRng.EntireRow.Hidden = True
If tCount > 0 Then tRng.EntireRow.Hidden = False
Next Tbl
End Sub