我记录了一个带有小计的宏,当我运行它时,这就是我得到的错误。错误与第一行相关
ActiveWorkbook.Worksheets("Celine HB").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Celine HB").AutoFilter.Sort.SortFields.Add Key:= _
Range("E1:E301"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption _
:=xlSortNormal
With ActiveWorkbook.Worksheets("Celine HB").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
答案 0 :(得分:1)
当工作表上没有设置AutoFilter
时,您将得到该错误。如果要测试过滤器是否存在,要处理该包装代码,此
If ActiveWorkbook.Worksheets("Celine HB").AutoFilterMode Then
' your code
Else
'No Filter set, what now?
End if