2012-05-04 177 views
0

如果我将区域语言格式设置为英语(英国),则使用此过滤器时出现问题,如果使用英语(美国),则此功能运行良好。 我的问题是,该过滤器不会使5月30日的选择不可见,它在该调用失败并转到错误部分。在Excel中过滤数据透视表

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

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

它过滤日期simular发布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 
+0

你有什么问题? – mischab1

+0

抱歉,尚不清楚添加更好的描述 – Damian

回答

1

久经考验的2003年EXCEL(与英国设置)

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

enter image description here

+0

不工作对不起!使用Excel 2007和Windows 7. – Damian

+0

嗯,我的印象是,你使用Excel 2003 ... –

相关问题