I am hoping someone would be able to assist me in getting this automatic sort working correctly. I have data in columns B through G, with headings. Column G is date updated. Whenever I change that date I would like the whole table to update putting the most recent updates on top.
Here is what I have in the code, which I created with a macro:
Private Sub Worksheet_Change(ByVal Target As Range)
Columns("B:G").Select
ActiveWorkbook.Worksheets("Sheet1").ListObjects("Table1").sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet1").ListObjects("Table1").sort.SortFields.Add _
Key:=Range("Table1[[#All],[Date" & Chr(10) & "Updated]]"), SortOn:=xlSortOnValues, Order _
:=xlDescending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").ListObjects("Table1").sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("B2").Select
End Sub
The current code sorts whenever data is entered in any of the cells, which causes me some frustration. Any help would be appreciated.
Thanks
Here is what I have in the code, which I created with a macro:
Private Sub Worksheet_Change(ByVal Target As Range)
Columns("B:G").Select
ActiveWorkbook.Worksheets("Sheet1").ListObjects("Table1").sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet1").ListObjects("Table1").sort.SortFields.Add _
Key:=Range("Table1[[#All],[Date" & Chr(10) & "Updated]]"), SortOn:=xlSortOnValues, Order _
:=xlDescending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").ListObjects("Table1").sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("B2").Select
End Sub
The current code sorts whenever data is entered in any of the cells, which causes me some frustration. Any help would be appreciated.
Thanks