宏多个工作表并筛选具有选定日期范围的所有工作表数据

时间:2019-04-30 09:49:18

标签: excel vba

如何在日期范围内过滤多张数据。我找不到解决方法。一个按钮,它需要过滤所有图纸数据。

Sub ApplyFilter()
    Dim wsDL As Worksheet
    Dim wsABC As Worksheet
    Dim rngAD As Range
    Dim wsO() As Worksheet
    wsO = Array(Google, Bing, Yahoo, Facebook, Amazon)
    Set wsABC = wsO
    Set wsDL = Sheets("DateList")
    Set rngAD = wsABC.Range("AllDates")

    'update the list of dates
    wsDL.Range("A1").CurrentRegion.ClearContents
    'rngAD.Offset(-1, 0).Resize(rngAD.Rows.Count + 1).Select
    rngAD.AdvancedFilter _
        Action:=xlFilterCopy, CriteriaRange:="", _
        CopyToRange:=wsDL.Range("A1"), Unique:=True
    wsDL.Range("A1").CurrentRegion.Sort _
        Key1:=wsDL.Range("A2"), Order1:=xlAscending, Header:=xlYes

    'filter the list
    wsABC.Range("Database").AdvancedFilter _
        Action:=xlFilterInPlace, _
        CriteriaRange:=wsABC.Range("G1:H2"), Unique:=False  
End Sub

0 个答案:

没有答案