I have the below sorting code that I have written that works well when the table name is always Table3. But my issue is I need it to be able to run no matter what the table name is. How can this be modified to achieve this? I cannot come up with a solution. I have tried searching the Web with no luck. Thanks in Advance.
VBA Code:
Sub SortTable()
Dim ws As Worksheet
Set ws = ActiveSheet
With ws.ListObjects("Table3").Sort
.SortFields.Clear
.SortFields.Add Key:=Range("Table3[W/O '#]"), Order:=xlAscending
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub