[英]Excel VBA Runtime Error 1004 ActiveSheet.ListObject.Range.Autofilter
I have the following VBA Script do different things, like refreshing Information. 我让以下VBA脚本执行不同的操作,例如刷新信息。 I also wrote a line to Filter the tables, but it gives me the Runtime Error 1004. 我还写了一行来过滤表,但它给了我Runtime Error 1004。
Sorry if my english is bad. 对不起,如果我的英语不好。 I'm no native speaker 我不是母语人士
Sub sync_and_sort()
ActiveWorkbook.RefreshAll
Sheets("Start").Range("sync").Copy
Dim column As Integer, first As Boolean
column = 11
first = True
For Each wks In Worksheets
For Each lio In wks.ListObjects
Sheets(wks.Name).Range(lio.Name).PasteSpecial Paste:=xlPasteValuesAndNumberFormats, _
Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Dim helper As String
helper = lio.Name + "[tatsächliches Enddatum]"
Sheets(wks.Name).ListObjects(lio.Name).Sort.SortFields.Clear
Sheets(wks.Name).ListObjects(lio.Name).Sort.SortFields.Add _
Key:=Sheets(wks.Name).Range(helper) _
, SortOn:=xlSortOnValues _
, Order:=xlAscending, DataOption:=xlSortTextAsNumbers
With Sheets(wks.Name).ListObjects(lio.Name). _
Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Sheets(wks.Name).Select
ActiveSheet.ListObjects(lio.Name).Range.AutoFilter Field:=11, _
Criterial:="WAHR"
Sheets(wks.Name).Range("A1").Select
Next lio
If first Then
first = False
Else
Sheets(wks.Name).Columns(column).Hidden = False
column = column + 1
End If
Next wks
End Sub
Thank you in advance. 先感谢您。
Well, The spelling of Criterial
in Criterial:="WAHR"
is wrong. 嗯,拼写Criterial
的Criterial:="WAHR"
是错误的。 It should be Criteria1:="WAHR"
. 它应该是Criteria1:="WAHR"
。 Notice the 1
? 注意1
? :) :)
Try this ( Tried and Tested ) 试试这个( 尝试和测试 )
ActiveSheet.ListObjects(lio.Name).Range.AutoFilter Field:=11, Criteria1:="WAHR"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.