excel 按日期筛选不显示筛选器选择

jfewjypa  于 2023-04-22  发布在  其他
关注(0)|答案(1)|浏览(126)

我做了一个过滤三列的宏。我只得到空白字段。
在手动进入三个过滤器选择(宏已经完成)并在所有三个上单击“OK”后,显示数据。
日期格式:02.01.2023

Sub Filter_Date()

    Dim ws As Worksheet: Set ws = Sheets("Source Data")
    Dim rg As Range: Set rg = ws.Range("A12:AA2758")
    
    rg.AutoFilter 25, "<=" & DateSerial(2023, 12, 30), xlAnd, "<>" & DateSerial(2022, 12, 31)
    rg.AutoFilter 26, "<=" & Date + 7, xlOr, "unconfirmed"
    rg.AutoFilter 27, "<=" & Date - 5
        
End Sub

uxhixvfz

uxhixvfz1#

将日期转换为Double

rg.AutoFilter 25, "<=" & CDbl(DateSerial(2023, 12, 30)), xlAnd, "<>" & CDbl(DateSerial(2022, 12, 31))
rg.AutoFilter 26, "<=" & CDbl(Date + 7), xlOr, "unconfirmed"
rg.AutoFilter 27, "<=" & CDbl(Date - 5)

相关问题