using cell data to filter pivot table (date field)

riverstar

New Member
Joined
May 9, 2012
Messages
2
I am using a macro to update the a filter on a pivot table. The below script works great when the field is text however I can not get it to work with a date value.

I have tried several differnt changes but cannot get it to work. It will clear the filter but does not appear to recognise the date value from the cell as a valid selection. I have even tried to converting the date to a text value first with no luck.

My Pivot table (Campaigns) has two filters (Group and Date) which both need to be updated from different cells (A1 and B1). Below is the script that works and updates the Group filter.

Any help would be much appreciated. I am new to playing with VBA and seem to be completely lost with this one.


Sub Apply_Reporting_Group_Filter()
Dim pvtTable As PivotTable
Dim pvtField As PivotField
Dim pvtItem As PivotItem
Dim filterReportingGroup As String

Set pvtTable = Worksheets("Sheet1").PivotTables("Campaigns")
Set pvtField = pvtTable.PivotFields("Reporting Group")

filterReportingGroup = Worksheets("Data Control").Range("A1")

For Each pvtItem In pvtField.PivotItems
If pvtItem.Value = filterReportingGroup Then
pvtField.CurrentPage = filterReportingGroup
Exit For
End If
Next pvtItem
End Sub
 
Last edited:

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Try something like this. No need to loop through each item in a Page field. You cannot select multiple items.

Rich (BB code):
Worksheets("Sheet1").PivotTables("Campaigns").PivotFields("Reporting Date").CurrentPage = Worksheets("Data Control").Range("B1").Value
 
Last edited:
Upvote 0
Better yet...

Rich (BB code):
Sub Apply_Reporting_Group_Filter()

    With Worksheets("Sheet1").PivotTables("Campaigns")
        .PivotFields("Reporting Group").CurrentPage = Worksheets("Data Control").Range("A1").Value
        .PivotFields("Reporting Date").CurrentPage = Worksheets("Data Control").Range("B1").Value
    End With

End Sub
 
Last edited:
Upvote 0
Hi there,

I have two pivot tables on the same worksheet that I want to filter based on the date entered in cell D7. Here is the code that I am using:


Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("D7")) Is Nothing Then Exit Sub
Application.EnableEvents = False
Sheet5.PivotTables("DB_Summary").PivotFields("Date").CurrentPage = Target.Value
Sheet5.PivotTables("DNB_Summary").PivotFields("Date").CurrentPage = Target.Value
Application.EnableEvents = True
ActiveWorkbook.RefreshAll
End Sub

This macro doesn't seem to do anything when I change the date in D7. I have tried to do some error testing by pasting the following code into a separate module:


Code:
Sub Test()
Application.EnableEvents = False
Sheet5.PivotTables("DB_Summary").PivotFields("Date").CurrentPage = Range("D7").Value
Sheet5.PivotTables("DNB_Summary").PivotFields("Date").CurrentPage = Range("D7").Value
Application.EnableEvents = True
ActiveWorkbook.RefreshAll
End Sub

When I walk-through the above code I get a Run-time error '1004': Unable to get the PivotFields property of the PivotTable class.

Any help would be appreciated!

Thanks!
 
Last edited:
Upvote 0
Hi everyone,

Just bumping up this thread to see if someone can address my question above.

Much appreciated!
 
Upvote 0
When I walk-through the above code I get a Run-time error '1004': Unable to get the PivotFields property of the PivotTable class.

Is the date in D7 a date that exists in the Date field?

Convert the D7 date value to a text string of the same date formatting as in the pagefield. Change the red date format to suit.
Rich (BB code):
Sheet5.PivotTables("DB_Summary").PivotFields("Date").CurrentPage = Format(Range("D7").Value, "m/d/yyyy")
Sheet5.PivotTables("DNB_Summary").PivotFields("Date").CurrentPage = Format(Range("D7").Value, "m/d/yyyy")

If that doesn't work, record a macro where you manually change the date in one of the pivot tables and post code. This could give some clues if you are referring to the correct field.
 
Last edited:
Upvote 0
Is the date in D7 a date that exists in the Date field?

Convert the D7 date value to a text string of the same date formatting as in the pagefield. Change the red date format to suit.
Code:
Sheet5.PivotTables("DB_Summary").PivotFields("Date").CurrentPage = Format(Range("D7").Value,[COLOR=#ff0000] "m/d/yyyy"[/COLOR])
Sheet5.PivotTables("DNB_Summary").PivotFields("Date").CurrentPage = Format(Range("D7").Value, [COLOR=#ff0000]"m/d/yyyy"[/COLOR])

If that doesn't work, record a macro where you manually change the date in one of the pivot tables and post code. This could give some clues if you are referring to the correct field.

Hi Alpha,

Yes, the date in D7 does exist in my data set.

I tested the code you posted, but I am receiving the same error message.

Here is the code that is generated when I manually filter the DNB_Summary pivor table:

Code:
Sub Macro1()
'
' Macro1 Macro
'
'
    With ActiveSheet.PivotTables("DNB_Summary").PivotFields("Date")
        .PivotItems("1/10/2011").Visible = False
        .PivotItems("1/11/2011").Visible = False
        .PivotItems("1/12/2011").Visible = False
        .PivotItems("1/13/2011").Visible = False
        .PivotItems("1/14/2011").Visible = False
        .PivotItems("1/16/2011").Visible = False
        .PivotItems("1/17/2011").Visible = False
        .PivotItems("1/18/2011").Visible = False
        .PivotItems("1/19/2011").Visible = False
        .PivotItems("1/20/2011").Visible = False
        .PivotItems("1/21/2011").Visible = False
        .PivotItems("1/24/2011").Visible = False
        .PivotItems("1/25/2011").Visible = False
        .PivotItems("1/26/2011").Visible = False
        .PivotItems("1/27/2011").Visible = False
        .PivotItems("1/28/2011").Visible = False
        .PivotItems("1/31/2011").Visible = False
        .PivotItems("2/1/2011").Visible = False
        .PivotItems("2/2/2011").Visible = False
        .PivotItems("2/3/2011").Visible = False
        .PivotItems("2/4/2011").Visible = False
        .PivotItems("2/7/2011").Visible = False
        .PivotItems("2/8/2011").Visible = False
        .PivotItems("2/9/2011").Visible = False
        .PivotItems("2/10/2011").Visible = False
        .PivotItems("2/11/2011").Visible = False
        .PivotItems("2/14/2011").Visible = False
        .PivotItems("2/15/2011").Visible = False
        .PivotItems("2/16/2011").Visible = False
        .PivotItems("2/17/2011").Visible = False
        .PivotItems("2/18/2011").Visible = False
        .PivotItems("2/20/2011").Visible = False
        .PivotItems("2/21/2011").Visible = False
        .PivotItems("2/22/2011").Visible = False
        .PivotItems("2/23/2011").Visible = False
        .PivotItems("2/24/2011").Visible = False
        .PivotItems("2/25/2011").Visible = False
    End With
    With ActiveSheet.PivotTables("DNB_Summary").PivotFields("Date")
        .PivotItems("2/26/2011").Visible = False
        .PivotItems("2/28/2011").Visible = False
        .PivotItems("3/1/2011").Visible = False
        .PivotItems("3/2/2011").Visible = False
        .PivotItems("3/3/2011").Visible = False
        .PivotItems("3/4/2011").Visible = False
        .PivotItems("3/7/2011").Visible = False
        .PivotItems("3/8/2011").Visible = False
        .PivotItems("3/9/2011").Visible = False
        .PivotItems("3/10/2011").Visible = False
        .PivotItems("3/11/2011").Visible = False
        .PivotItems("3/14/2011").Visible = False
        .PivotItems("3/15/2011").Visible = False
        .PivotItems("3/16/2011").Visible = False
        .PivotItems("3/17/2011").Visible = False
        .PivotItems("3/18/2011").Visible = False
        .PivotItems("3/21/2011").Visible = False
        .PivotItems("3/22/2011").Visible = False
        .PivotItems("3/23/2011").Visible = False
        .PivotItems("3/24/2011").Visible = False
        .PivotItems("3/25/2011").Visible = False
        .PivotItems("3/28/2011").Visible = False
        .PivotItems("3/29/2011").Visible = False
        .PivotItems("3/30/2011").Visible = False
        .PivotItems("3/31/2011").Visible = False
        .PivotItems("4/1/2011").Visible = False
        .PivotItems("4/4/2011").Visible = False
        .PivotItems("4/5/2011").Visible = False
        .PivotItems("4/6/2011").Visible = False
        .PivotItems("4/7/2011").Visible = False
        .PivotItems("4/8/2011").Visible = False
        .PivotItems("4/11/2011").Visible = False
        .PivotItems("4/12/2011").Visible = False
        .PivotItems("4/13/2011").Visible = False
        .PivotItems("4/14/2011").Visible = False
        .PivotItems("4/15/2011").Visible = False
        .PivotItems("4/18/2011").Visible = False
    End With
    With ActiveSheet.PivotTables("DNB_Summary").PivotFields("Date")
        .PivotItems("4/19/2011").Visible = False
        .PivotItems("4/20/2011").Visible = False
        .PivotItems("4/21/2011").Visible = False
        .PivotItems("4/22/2011").Visible = False
        .PivotItems("4/25/2011").Visible = False
        .PivotItems("4/26/2011").Visible = False
        .PivotItems("4/27/2011").Visible = False
        .PivotItems("4/28/2011").Visible = False
        .PivotItems("4/29/2011").Visible = False
        .PivotItems("5/2/2011").Visible = False
        .PivotItems("5/3/2011").Visible = False
        .PivotItems("5/4/2011").Visible = False
        .PivotItems("5/5/2011").Visible = False
        .PivotItems("5/6/2011").Visible = False
        .PivotItems("5/9/2011").Visible = False
        .PivotItems("5/10/2011").Visible = False
        .PivotItems("5/11/2011").Visible = False
        .PivotItems("5/12/2011").Visible = False
        .PivotItems("5/13/2011").Visible = False
        .PivotItems("5/14/2011").Visible = False
        .PivotItems("5/15/2011").Visible = False
        .PivotItems("5/16/2011").Visible = False
        .PivotItems("5/17/2011").Visible = False
        .PivotItems("5/18/2011").Visible = False
        .PivotItems("5/23/2011").Visible = False
        .PivotItems("5/24/2011").Visible = False
        .PivotItems("5/25/2011").Visible = False
        .PivotItems("5/26/2011").Visible = False
        .PivotItems("5/27/2011").Visible = False
        .PivotItems("5/30/2011").Visible = False
        .PivotItems("5/31/2011").Visible = False
        .PivotItems("6/1/2011").Visible = False
        .PivotItems("6/2/2011").Visible = False
        .PivotItems("6/3/2011").Visible = False
        .PivotItems("6/6/2011").Visible = False
        .PivotItems("6/7/2011").Visible = False
        .PivotItems("6/8/2011").Visible = False
    End With
    With ActiveSheet.PivotTables("DNB_Summary").PivotFields("Date")
        .PivotItems("6/9/2011").Visible = False
        .PivotItems("6/10/2011").Visible = False
        .PivotItems("6/13/2011").Visible = False
        .PivotItems("6/14/2011").Visible = False
        .PivotItems("6/15/2011").Visible = False
        .PivotItems("6/16/2011").Visible = False
        .PivotItems("6/17/2011").Visible = False
        .PivotItems("6/20/2011").Visible = False
        .PivotItems("6/21/2011").Visible = False
        .PivotItems("6/22/2011").Visible = False
        .PivotItems("6/23/2011").Visible = False
        .PivotItems("6/24/2011").Visible = False
        .PivotItems("6/27/2011").Visible = False
        .PivotItems("6/28/2011").Visible = False
        .PivotItems("6/29/2011").Visible = False
        .PivotItems("6/30/2011").Visible = False
        .PivotItems("7/1/2011").Visible = False
        .PivotItems("7/4/2011").Visible = False
        .PivotItems("7/5/2011").Visible = False
        .PivotItems("7/6/2011").Visible = False
        .PivotItems("7/7/2011").Visible = False
        .PivotItems("7/8/2011").Visible = False
        .PivotItems("7/11/2011").Visible = False
        .PivotItems("7/12/2011").Visible = False
        .PivotItems("7/13/2011").Visible = False
        .PivotItems("7/14/2011").Visible = False
        .PivotItems("7/15/2011").Visible = False
        .PivotItems("7/18/2011").Visible = False
        .PivotItems("7/19/2011").Visible = False
        .PivotItems("7/20/2011").Visible = False
        .PivotItems("7/21/2011").Visible = False
        .PivotItems("7/22/2011").Visible = False
        .PivotItems("7/25/2011").Visible = False
        .PivotItems("7/26/2011").Visible = False
        .PivotItems("7/27/2011").Visible = False
        .PivotItems("7/28/2011").Visible = False
        .PivotItems("7/29/2011").Visible = False
    End With
    With ActiveSheet.PivotTables("DNB_Summary").PivotFields("Date")
        .PivotItems("8/1/2011").Visible = False
        .PivotItems("8/2/2011").Visible = False
        .PivotItems("8/3/2011").Visible = False
        .PivotItems("8/4/2011").Visible = False
        .PivotItems("8/5/2011").Visible = False
        .PivotItems("8/8/2011").Visible = False
        .PivotItems("8/9/2011").Visible = False
        .PivotItems("8/10/2011").Visible = False
        .PivotItems("8/11/2011").Visible = False
        .PivotItems("8/12/2011").Visible = False
        .PivotItems("8/15/2011").Visible = False
        .PivotItems("8/16/2011").Visible = False
        .PivotItems("8/17/2011").Visible = False
        .PivotItems("8/18/2011").Visible = False
        .PivotItems("8/19/2011").Visible = False
        .PivotItems("8/22/2011").Visible = False
        .PivotItems("8/23/2011").Visible = False
        .PivotItems("8/24/2011").Visible = False
        .PivotItems("8/25/2011").Visible = False
        .PivotItems("8/26/2011").Visible = False
        .PivotItems("8/27/2011").Visible = False
        .PivotItems("5/22/2012").Visible = False
        .PivotItems("5/23/2012").Visible = False
        .PivotItems("5/24/2012").Visible = False
        .PivotItems("5/25/2012").Visible = False
        .PivotItems("5/28/2012").Visible = False
        .PivotItems("5/29/2012").Visible = False
        .PivotItems("5/30/2012").Visible = False
        .PivotItems("5/31/2012").Visible = False
        .PivotItems("6/4/2012").Visible = False
        .PivotItems("6/5/2012").Visible = False
        .PivotItems("6/6/2012").Visible = False
        .PivotItems("6/7/2012").Visible = False
        .PivotItems("6/8/2012").Visible = False
        .PivotItems("6/11/2012").Visible = False
        .PivotItems("6/12/2012").Visible = False
        .PivotItems("6/13/2012").Visible = False
    End With
    With ActiveSheet.PivotTables("DNB_Summary").PivotFields("Date")
        .PivotItems("6/14/2012").Visible = False
        .PivotItems("6/15/2012").Visible = False
        .PivotItems("6/18/2012").Visible = False
        .PivotItems("6/19/2012").Visible = False
        .PivotItems("6/20/2012").Visible = False
        .PivotItems("6/21/2012").Visible = False
        .PivotItems("6/22/2012").Visible = False
        .PivotItems("6/25/2012").Visible = False
        .PivotItems("6/26/2012").Visible = False
        .PivotItems("6/27/2012").Visible = False
        .PivotItems("6/28/2012").Visible = False
        .PivotItems("6/29/2012").Visible = False
        .PivotItems("7/2/2012").Visible = False
        .PivotItems("7/3/2012").Visible = False
        .PivotItems("7/4/2012").Visible = False
        .PivotItems("7/5/2012").Visible = False
        .PivotItems("7/6/2012").Visible = False
        .PivotItems("7/9/2012").Visible = False
        .PivotItems("7/10/2012").Visible = False
        .PivotItems("7/12/2012").Visible = False
        .PivotItems("7/13/2012").Visible = False
        .PivotItems("7/16/2012").Visible = False
        .PivotItems("7/17/2012").Visible = False
        .PivotItems("7/18/2012").Visible = False
        .PivotItems("7/19/2012").Visible = False
        .PivotItems("7/20/2012").Visible = False
        .PivotItems("7/23/2012").Visible = False
        .PivotItems("7/24/2012").Visible = False
        .PivotItems("7/25/2012").Visible = False
        .PivotItems("7/26/2012").Visible = False
        .PivotItems("7/27/2012").Visible = False
        .PivotItems("7/30/2012").Visible = False
        .PivotItems("7/31/2012").Visible = False
        .PivotItems("8/1/2012").Visible = False
        .PivotItems("8/2/2012").Visible = False
        .PivotItems("8/3/2012").Visible = False
        .PivotItems("8/6/2012").Visible = False
    End With
    With ActiveSheet.PivotTables("DNB_Summary").PivotFields("Date")
        .PivotItems("8/7/2012").Visible = False
        .PivotItems("8/8/2012").Visible = False
        .PivotItems("8/9/2012").Visible = False
        .PivotItems("8/10/2012").Visible = False
        .PivotItems("8/13/2012").Visible = False
        .PivotItems("8/14/2012").Visible = False
        .PivotItems("8/15/2012").Visible = False
        .PivotItems("8/16/2012").Visible = False
        .PivotItems("8/17/2012").Visible = False
        .PivotItems("8/20/2012").Visible = False
        .PivotItems("8/21/2012").Visible = False
        .PivotItems("8/22/2012").Visible = False
        .PivotItems("8/23/2012").Visible = False
        .PivotItems("8/24/2012").Visible = False
        .PivotItems("1/7/2013").Visible = False
        .PivotItems("1/8/2013").Visible = False
        .PivotItems("1/9/2013").Visible = False
        .PivotItems("1/10/2013").Visible = False
        .PivotItems("1/11/2013").Visible = False
        .PivotItems("1/12/2013").Visible = False
        .PivotItems("1/13/2013").Visible = False
        .PivotItems("1/14/2013").Visible = False
        .PivotItems("1/15/2013").Visible = False
        .PivotItems("1/16/2013").Visible = False
        .PivotItems("1/17/2013").Visible = False
        .PivotItems("1/18/2013").Visible = False
        .PivotItems("1/21/2013").Visible = False
        .PivotItems("1/22/2013").Visible = False
        .PivotItems("1/23/2013").Visible = False
        .PivotItems("1/24/2013").Visible = False
        .PivotItems("1/25/2013").Visible = False
        .PivotItems("1/27/2013").Visible = False
        .PivotItems("1/28/2013").Visible = False
        .PivotItems("1/29/2013").Visible = False
        .PivotItems("1/30/2013").Visible = False
        .PivotItems("1/31/2013").Visible = False
        .PivotItems("2/1/2013").Visible = False
    End With
    With ActiveSheet.PivotTables("DNB_Summary").PivotFields("Date")
        .PivotItems("2/2/2013").Visible = False
        .PivotItems("2/3/2013").Visible = False
        .PivotItems("2/4/2013").Visible = False
        .PivotItems("2/5/2013").Visible = False
        .PivotItems("2/6/2013").Visible = False
        .PivotItems("2/7/2013").Visible = False
        .PivotItems("2/8/2013").Visible = False
        .PivotItems("2/9/2013").Visible = False
        .PivotItems("2/10/2013").Visible = False
        .PivotItems("2/11/2013").Visible = False
        .PivotItems("2/12/2013").Visible = False
        .PivotItems("2/13/2013").Visible = False
        .PivotItems("2/14/2013").Visible = False
        .PivotItems("2/15/2013").Visible = False
        .PivotItems("2/18/2013").Visible = False
        .PivotItems("2/19/2013").Visible = False
        .PivotItems("2/20/2013").Visible = False
        .PivotItems("2/21/2013").Visible = False
        .PivotItems("2/22/2013").Visible = False
        .PivotItems("2/25/2013").Visible = False
        .PivotItems("2/26/2013").Visible = False
        .PivotItems("2/27/2013").Visible = False
        .PivotItems("2/28/2013").Visible = False
        .PivotItems("3/1/2013").Visible = False
        .PivotItems("3/2/2013").Visible = False
        .PivotItems("3/4/2013").Visible = False
        .PivotItems("3/5/2013").Visible = False
        .PivotItems("3/6/2013").Visible = False
        .PivotItems("3/7/2013").Visible = False
        .PivotItems("3/8/2013").Visible = False
        .PivotItems("3/11/2013").Visible = False
        .PivotItems("3/12/2013").Visible = False
        .PivotItems("3/13/2013").Visible = False
        .PivotItems("3/14/2013").Visible = False
        .PivotItems("3/15/2013").Visible = False
        .PivotItems("3/17/2013").Visible = False
        .PivotItems("3/18/2013").Visible = False
    End With
    With ActiveSheet.PivotTables("DNB_Summary").PivotFields("Date")
        .PivotItems("3/19/2013").Visible = False
        .PivotItems("3/20/2013").Visible = False
        .PivotItems("3/21/2013").Visible = False
        .PivotItems("3/22/2013").Visible = False
        .PivotItems("3/23/2013").Visible = False
        .PivotItems("3/24/2013").Visible = False
        .PivotItems("3/25/2013").Visible = False
        .PivotItems("3/26/2013").Visible = False
        .PivotItems("3/27/2013").Visible = False
        .PivotItems("3/28/2013").Visible = False
        .PivotItems("3/29/2013").Visible = False
        .PivotItems("3/30/2013").Visible = False
        .PivotItems("3/31/2013").Visible = False
        .PivotItems("4/1/2013").Visible = False
        .PivotItems("4/2/2013").Visible = False
        .PivotItems("4/3/2013").Visible = False
        .PivotItems("4/4/2013").Visible = False
        .PivotItems("4/5/2013").Visible = False
        .PivotItems("4/8/2013").Visible = False
        .PivotItems("4/9/2013").Visible = False
        .PivotItems("4/10/2013").Visible = False
        .PivotItems("4/11/2013").Visible = False
        .PivotItems("4/12/2013").Visible = False
        .PivotItems("4/15/2013").Visible = False
        .PivotItems("4/16/2013").Visible = False
        .PivotItems("4/17/2013").Visible = False
        .PivotItems("4/18/2013").Visible = False
        .PivotItems("4/19/2013").Visible = False
        .PivotItems("4/21/2013").Visible = False
        .PivotItems("4/22/2013").Visible = False
        .PivotItems("4/23/2013").Visible = False
        .PivotItems("4/24/2013").Visible = False
        .PivotItems("4/25/2013").Visible = False
        .PivotItems("4/26/2013").Visible = False
        .PivotItems("4/28/2013").Visible = False
        .PivotItems("4/29/2013").Visible = False
        .PivotItems("4/30/2013").Visible = False
    End With
    With ActiveSheet.PivotTables("DNB_Summary").PivotFields("Date")
        .PivotItems("5/1/2013").Visible = False
        .PivotItems("5/2/2013").Visible = False
        .PivotItems("5/3/2013").Visible = False
        .PivotItems("5/5/2013").Visible = False
        .PivotItems("5/6/2013").Visible = False
        .PivotItems("5/7/2013").Visible = False
        .PivotItems("5/8/2013").Visible = False
        .PivotItems("5/9/2013").Visible = False
        .PivotItems("5/10/2013").Visible = False
        .PivotItems("5/11/2013").Visible = False
        .PivotItems("5/12/2013").Visible = False
        .PivotItems("5/13/2013").Visible = False
        .PivotItems("5/14/2013").Visible = False
        .PivotItems("5/15/2013").Visible = False
        .PivotItems("5/16/2013").Visible = False
        .PivotItems("(blank)").Visible = False
        .PivotItems("5/17/2013").Visible = False
        .PivotItems("5/18/2013").Visible = False
        .PivotItems("5/19/2013").Visible = False
        .PivotItems("5/20/2013").Visible = False
        .PivotItems("5/21/2013").Visible = False
        .PivotItems("5/22/2013").Visible = False
        .PivotItems("5/23/2013").Visible = False
        .PivotItems("5/24/2013").Visible = False
    End With
    ActiveSheet.PivotTables("DNB_Summary").PivotFields("Date").ClearAllFilters
End Sub

:eeek: Hope that doesn't crash the forum!

Here is another version of filtering that I recorded:

Code:
ActiveSheet.PivotTables("DNB_Summary").PivotFields("Date").ClearAllFilters
    ActiveSheet.PivotTables("DNB_Summary").PivotFields("Date").PivotFilters.Add _
        Type:=xlSpecificDate, Value1:="5/25/2013"

Thanks for your help with this Alpha... any more thoughts?
 
Upvote 0
Here is another version of filtering that I recorded:

Code:
ActiveSheet.PivotTables("DNB_Summary").PivotFields("Date").ClearAllFilters
    ActiveSheet.PivotTables("DNB_Summary").PivotFields("Date").PivotFilters.Add _
        Type:=xlSpecificDate, Value1:="5/25/2013"

Thy this. It's your recorded macro modified.
Code:
With Sheet5.PivotTables("DNB_Summary").PivotFields("Date")
    .ClearAllFilters
    .PivotFilters.Add Type:=xlSpecificDate, Value1:=Format(Range("D7").Value, "m/d/yyyy")
End With
 
Upvote 0

Forum statistics

Threads
1,224,825
Messages
6,181,191
Members
453,021
Latest member
pingpong7117

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top