用VBA做自动更新高级筛选 我做个高级筛选但不能自动更新,想请教各位如 ...
发布网友
发布时间:2024-10-24 03:00
我来回答
共1个回答
热心网友
时间:2024-10-29 22:10
从以下的示例中,以及FILTE这个对象的属性来看,无法遍历筛选列出的项目。我觉的可以换个方法,例如生成透视表,再遍历透视表中的值,然后再删除透视表。
Dim w As Worksheet
Dim filterArray()
Dim currentFiltRange As String
Sub ChangeFilters()
Set w = Worksheets("Crew")
With w.AutoFilter
currentFiltRange = .Range.Address
With .Filters
ReDim filterArray(1 To .Count, 1 To 3)
For f = 1 To .Count
With .Item(f)
If .On Then
filterArray(f, 1) = .Criteria1
If .Operator Then
filterArray(f, 2) = .Operator
filterArray(f, 3) = .Criteria2
End If
End If
End With
Next
End With
End With
w.AutoFilterMode = False
w.Range("A1").AutoFilter field:=1, Criteria1:="S"
End Sub