Good Afternoon Stack Overflow Patrons:
I, like many others, are getting the dreaded 1004 Runtime Error when attempting to sort a table... but here is the kicker....
This worked for me:
Sub Sort_Compiled_Data_Sheet()
Dim sht as worksheet
Set sht = ActiveWorkbook.Worksheets("Compiled_Data")
sht.Activate
With sht.ListObjects("Compiled_Data").Sort
.SortFields.Clear
.SortFields.Add Key:=Range("Compiled_Data[Date]"), SortOn:=xlSortOnValues, _
Order:=xlAscending
.SortFields.Add Key:=Range("Compiled_Data[Contractor]"), _
SortOn:=xlSortOnValues, Order:=xlAscending
.SortFields.Add Key:=Range("Compiled_Data[Customer]"), _
SortOn:=xlSortOnValues, Order:=xlAscending
.SortFields.Add Key:=Range("Compiled_Data[Item]"), SortOn:=xlSortOnValues, _
Order:=xlAscending
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub