I have the following VBA Script do different things, like refreshing Information. I also wrote a line to Filter the tables, but it gives me the 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. It should be Criteria1:="WAHR"
. Notice the 1
? :)
Try this ( Tried and Tested )
ActiveSheet.ListObjects(lio.Name).Range.AutoFilter Field:=11, Criteria1:="WAHR"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.