tony.reynolds
Board Regular
- Joined
- Jul 8, 2010
- Messages
- 97
Im trying to sort my workbook by date and the code below works ok but it seems to have issues in some circumstances due to othe code conflickting
is there a better option to sort the sheet by the date values in column A:A
I also wanted it the remove or not show the sort button so the user can fidddle with the sorting
Ny help would be really appreciated
is there a better option to sort the sheet by the date values in column A:A
I also wanted it the remove or not show the sort button so the user can fidddle with the sorting
Code:
Sub SortByDate()
Sheets("Master Accounts").Activate
Worksheets("Master Accounts").Unprotect (3221)
Set ReturnCell = ActiveCell
Application.ScreenUpdating = False
Rows("4:4").Select
Selection.AutoFilter
ActiveWorkbook.Worksheets("Master Accounts").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Master Accounts").AutoFilter.Sort.SortFields.Add Key _
:=Range("A4"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Master Accounts").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Selection.AutoFilter
Worksheets("Master Accounts").Protect (3221)
ReturnCell.Activate
Application.ScreenUpdating = True
End Sub
Ny help would be really appreciated