|
|
此文章由 roseinsummer 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 roseinsummer 所有!转贴必须注明作者、出处和本声明,并保持内容完整
I created a macro to filter a pivot table by date. On the pivot table sheet, I entered a date into Cell M1. The macro filters the pivot table based on that date. Unfortunately, I keep getting an error message: The date you entered is not a valid date. Please try again. Here is my macro as follows:
Sub Update()
Worksheets("pivot").Select
ActiveSheet.PivotTables("PivotTable6").RefreshTable
With ActiveSheet.PivotTables("PivotTable6").PivotFields("SOF")
.PivotItems("(blank)").Visible = False
End With
With ActiveSheet.PivotTables("PivotTable6").PivotFields( _
"Sof Details - End Date (Trans)")
.PivotItems("(blank)").Visible = False
End With
Dim EndDate As Date
EndDate = Worksheets("pivot").Range("M1").Value
ActiveSheet.PivotTables("PivotTable6").PivotFields( _
"Sof Details - End Date (Trans)").PivotFilters.Add Type:=xlBeforeOrEqualTo, _
Value1:=EndDate
End Sub
Can anybody help me with this ? Thanks in advance. I think this may give others a chance to understand macro more . |
|