如果我将区域语言格式设置为英语(英国),则使用此过滤器时出现问题,如果使用英语(美国),则此功能运行良好。 我的问题是,该过滤器不会使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
你有什么问题? – mischab1
抱歉,尚不清楚添加更好的描述 – Damian