The macro below is a custom sort that I recorded. I replaced the actual table name with variable so I can run this for any other table name. I didn't want it to be specific to one name. When I run the macro I get a:
Run-time error '1004': the item with the specified name wasn't found
When I click the help button it sends me to Excel help menu. Could you guys let me know what I am missing? And if possible is there a way to shorten up my code. I know recordings can be long.
**Note all of this is in a table
Dim sh As Worksheet
Dim TableName As String
Set sh = ActiveSheet
TableName = sh.Name
ActiveWorkbook.Worksheets(TableName).ListObjects(TableName).sort. _
SortFields.Clear
ActiveWorkbook.Worksheets(TableName).ListObjects(TableName).sort. _
SortFields.Add Key:=Range(TableName, [BEVEL]), SortOn:=xlSortOnValues,
Order:=xlAscending, _
CustomOrder:="BEVEL_YES_MITER,BEVEL_NO_RADIUS", DataOption:=xlSortNormal _
ActiveWorkbook.Worksheets(TableName).ListObjects("TableName").sort. _
SortFields.Add Key:=Range(TableName, [MATERIAL]), SortOn:=xlSortOnValues, _
Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets(TableName).ListObjects(TableName).sort. _
SortFields.Add Key:=Range(TableName, [Length]), SortOn:=xlSortOnValues, _
Order:=xlDescending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets(TableName).ListObjects(TableName).sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Selection.AutoFilter
End Sub