Auto Sort Assistance XL2010

reem01

New Member
Joined
Nov 3, 2006
Messages
10
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
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Forum statistics

Threads
1,224,591
Messages
6,179,769
Members
452,941
Latest member
Greayliams

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top