对表进行排序的应用程序定义或对象定义的错误

时间:2016-09-26 09:36:27

标签: excel vba excel-vba

您好我试图在我已经制作的表格中对数据进行排序。这是我的代码:

Dim tbl As ListObject
Set tbl = ws1.ListObjects("PlanDataTable")
Dim so As Sort
With tbl.Sort
With .SortFields
    .Clear
    .Add Range("tbl[[#All],[PlanType]]"), SortOn:=xlSortOnValues, Order:=xlAscending
End With
.Header = xlYes
.Orientation = xlTopToBottom
.Apply
End With

当我到达.Add Range("tbl[[#All],[PlanType]]"), SortOn:=xlSortOnValues, Order:=xlAscending时,我得到应用程序定义的错误并且不知道为什么。不要以为有人知道为什么

0 个答案:

没有答案