To sort the data, I have two identical macros. The only distinction is in the sort order of the columns. When executed manually, both macros function properly, but when launched from a custom button, SortByDate returns an error. SortByPPR operates as intended. There are no noticeable setup variations.
Cannot execute the macro is the message.
It's possible that this workbook's macro won't work or that all macros are disabled.
Sub SortByDate()
'
' SortByDate Macro
'
'
Range("A6:O35").Select
ActiveWorkbook.ActiveSheet.Sort.SortFields.Clear
ActiveWorkbook.ActiveSheet.Sort.SortFields.Add2 Key:=Range("F6:F35") _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.ActiveSheet.Sort
.SetRange Range("A6:O35")
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
Sub SortByPPR()
'
' SortByPPR Macro
'
Range("A6:O35").Select
ActiveWorkbook.ActiveSheet.Sort.SortFields.Clear
ActiveWorkbook.ActiveSheet.Sort.SortFields.Add2 Key:=Range("b6:b35") _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.ActiveSheet.Sort
.SetRange Range("A6:O35")
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
'
End Sub