dpalomino1009
New Member
- Joined
- Mar 3, 2019
- Messages
- 20
Hello,
I'm trying to sort 3 columns in a table that goes from A2-G192, but the code I came up with is not working. Not sure where I went wrong. Posting the code below, please let me know.
Thank you,
I'm trying to sort 3 columns in a table that goes from A2-G192, but the code I came up with is not working. Not sure where I went wrong. Posting the code below, please let me know.
Thank you,
Code:
Private Sub Worksheet_Change(ByVal Target As Range)On Error Resume Next
Application.ScreenUpdating = False
If Not Intersect(Target, Range("E2:E192")) Is Nothing Then
With Sheets("User iMac & PC").ListObjects("Table1").Sort
.SortFields.Clear
.SortFields.Add Key1:=Range("Table1[Names]"), SortOn:=xlSortOnCellColor, Order:=xlAscending
.SortFields.Add Key2:=Range("Table1[A-Z]"), SortOn:=xlSortOnValues, Order:=xlAscending
.SortFields.Add Key3:=Range("Table1 [Names]"), SortOn:=xlSortOnValues, Order:=xlAscending
.SetRange Range("Table1")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End If
Application.ScreenUpdating = True
End Sub