Excel 2013, can data be re-sorted automatically?
I don't like leaving questions unanswered when they've already been answered it he comments. You can read the history in the comments but here is the final solution:
Private Sub Worksheet_Calculate()
'If the active sheet is called "Strategies", then this reapplies the filter for two tables and re-sorts them
Const wsName As String = "Strategies"
If ActiveSheet.Name = wsName Then
'Freeze everything and turn off events
With Application
.ScreenUpdating = False
.EnableEvents = False
.DisplayAlerts = False
End With
'Update Table2
With Worksheets(wsName).ListObjects("Table2")
.AutoFilter.ApplyFilter
With .Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End With
'Update Table3
With Worksheets(wsName).ListObjects("Table3")
.AutoFilter.ApplyFilter
With .Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End With
'Unfreeze things and turn events back on
With Application
.ScreenUpdating = True
.EnableEvents = True
.DisplayAlerts = True
End With
End If
End Sub
You could probably even shorten the filtering and sorting to just
With Worksheets(wsName).ListObjects("Table2")
.AutoFilter.ApplyFilter
.Sort.Apply
End With
This is a community wiki because I did not derive the solution. You can edit it if you want but all I did was transcribe the problem found in the comments and clean up the code a bit.