Simple macro, works just fine when I'm recording it, and looks like what I've used in the past. I've tried a couple of minor modifications, still and getting an error. Obviously I'm missing "something."
TIA!!
TIA!!
Code:
Sub Sort_XDATES1()
'
' tm_Sort_XDATES Macro
'
Application.Volatile True
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.DisplayStatusBar = True
'
Dim LastRow As Long
Dim LastCol As Integer
Dim thiswksht As Worksheet
'
'
Sheet2.Activate
Set thiswksht = ActiveSheet
'
If thiswksht.AutoFilterMode Then
AutoFilterMode = False
End If
'
With thiswksht
LastRow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
LastCol = Cells(1, Columns.Count).End(xlToLeft).Column
End With
Range("A1", Cells(LastRow, LastCol)).Select
Selection.Name = "tbl_P"
'
thiswksht.Sort.SortFields.Clear
thiswksht.Sort.SortFields.Add Key:=Range("A1", Cells(LastRow, LastCol)), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With thiswksht.Sort
.SetRange Range("A1", Cells(LastRow, LastCol))
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("A1").Select
End Sub