【问题标题】:Filter Pivot in Excel在 Excel 中筛选数据透视表
【发布时间】:2012-05-14 04:52:48
【问题描述】:

如果我将区域语言格式设置为英语(英国),我会遇到此过滤器的问题,如果我使用英语(美国),它会很好地工作。 我的问题是过滤器没有使 5 月 30 日的选择不可见,它在该调用中失败并转到错误部分。

http://wikisend.com/download/138750/Pivottable.xls

这是一个已知的错误吗? http://support.microsoft.com/default.aspx?scid=kb;en-us;114822&Product=xlw

它过滤日期模拟发布Filter pivottable in Excel 2003

Sub Filter()
    Dim PvtItem As PivotItem
    Dim ws As Worksheet

    On Error GoTo Whoa1

    Set ws = Sheets("pivot")

    '~~> Show All
    For Each PvtItem In ws.PivotTables("PivotTable1").PivotFields("Date").PivotItems
        PvtItem.Visible = True
    Next

    On Error GoTo Whoa2 '<~~ If no match found in Pivot

    '~~> Show Only the relevant
    For Each PvtItem In ws.PivotTables("PivotTable1").PivotFields("Date").PivotItems
        If Format(PvtItem.Value, "DD/MM/YYYY") <> Format(Range("today"), "DD/MM/YYYY") Then
            PvtItem.Visible = False
        End If
    Next

    Exit Sub
Whoa1:
    MsgBox Err.Description
    Exit Sub
Whoa2:
    '~~> Show All
    For Each PvtItem In ws.PivotTables("PivotTable1").PivotFields("Date").PivotItems
        PvtItem.Visible = True
    Next
End Sub

【问题讨论】:

  • 抱歉不清楚添加了更好的描述

标签: vba excel excel-2007 excel-2003


【解决方案1】:

在 EXCEL 2003 中试用和测试(使用英国设置)

右键单击快照中显示的日期字段,然后单击Field Settings,然后单击Number。如图所示设置日期格式。现在尝试相同的代码。

【讨论】:

    猜你喜欢
    • 2012-02-20
    • 1970-01-01
    • 1970-01-01
    • 2021-11-30
    • 1970-01-01
    • 1970-01-01
    • 2019-02-02
    • 2013-10-02
    • 2012-09-13
    相关资源
    最近更新 更多