Well if you don't want zeros in costs, that's one click in the filtering and if you don't want blanks in costs that's another click, but I can pre-click with code.
Option Explicit
Sub ClearCostsTable()
Dim tbl As ListObject
Set tbl = Worksheets("Costs").ListObjects("Costs")
If tbl.ListRows.Count >= 1 Then
tbl.DataBodyRange.AutoFilter 3
tbl.DataBodyRange.Delete
End If
End Sub
Sub LoopAllTables()
ClearCostsTable
Application.ScreenUpdating = False
Dim tbl As ListObject, tblCosts As ListObject
Dim ws As Worksheet, wsCosts As Worksheet, c As Long: c = 0
Set wsCosts = Worksheets("Costs"): Set tblCosts = wsCosts.ListObjects("Costs")
For Each ws In ThisWorkbook.Worksheets
If ws.Name Like "Day" & "*" Then
For Each tbl In ws.ListObjects
If tbl.ListRows.Count = 0 Then GoTo 1
With tbl.DataBodyRange
If c = 0 Then
.Copy tblCosts.HeaderRowRange.Offset(1)
Else
.Copy tblCosts.DataBodyRange.Rows(c)
End If
c = tblCosts.DataBodyRange.Rows.Count + 1
End With
1 Next tbl
End If
Next ws
tblCosts.Range.ClearFormats
tblCosts.TableStyle = "TableStyleMedium21"
FilterCosts
Application.ScreenUpdating = True
End Sub
Sub FilterCosts()
Application.ScreenUpdating = False
Dim tblCosts As ListObject
Dim wsCosts As Worksheet
Set wsCosts = Worksheets("Costs")
Set tblCosts = wsCosts.ListObjects("Costs")
With tblCosts.DataBodyRange
.AutoFilter 3, "<>"
.AutoFilter 3, ">0"
End With
Application.ScreenUpdating = True
End Sub
Bookmarks