Hello
I've got some code below attached to a button that works in Excel 365 to sort a Table, which throws up Error 438 when running in Excel 2010
Is there something I can modify so that it run on Excel 2010?
(As you might be able to tell, I can't write VBA from scratch,, but am trying to to learn how to edit recorded macros! Any help greatly appreciated)
I've got some code below attached to a button that works in Excel 365 to sort a Table, which throws up Error 438 when running in Excel 2010
Is there something I can modify so that it run on Excel 2010?
VBA Code:
Sub SortEventsByDate()
Sheets("Events").Select
ActiveSheet.Unprotect Password:="password"
ActiveWorkbook.Worksheets("Events").ListObjects("tbl_Events").Sort.SortFields. _
Clear
ActiveWorkbook.Worksheets("Events").ListObjects("tbl_Events").Sort.SortFields. _
Add2 Key:=Range("tbl_Events[[#All],[Event Date]]"), SortOn:=xlSortOnValues _
, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Events").ListObjects("tbl_Events").Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Sheets("Events").Select
ActiveSheet.Protect Password:="password", AllowFiltering:=True, AllowSorting:=True, AllowFormattingCells:=False, AllowFormattingColumns:=False, AllowFormattingRows:=False, AllowInsertingColumns:=False, AllowDeletingColumns:=False
End Sub
(As you might be able to tell, I can't write VBA from scratch,, but am trying to to learn how to edit recorded macros! Any help greatly appreciated)