Microsoft Excel - filter a date in a pivot table based on the content of a cell

Asked By Cherifa Hima on 04-Feb-13 09:53 PM
Hi,
I have this code that allows me to filter a date in a pivotable based on cell G1. How to modify the code to filter the date between two dates based on cell G1 and G2. Thanks.

Sub Worksheet_Change()
   
   ActiveSheet.PivotTables("PivotTable1").PivotFields("Date").CurrentPage = Range("G1").Text
   
    End Sub
Pete Bradshaw replied to Cherifa Hima on 07-Feb-13 07:39 AM
Hi,

Have you tried using Range("G1").value instead?

I use this on some of my workbooks and it seems to work.

Cheers

Pete
Cherifa Hima replied to Pete Bradshaw on 07-Feb-13 09:33 AM
Thanks. I want to filter dates based on startdate & Enddate from two ranges. And yes, I can use Range("G1").value for startdate but I need to use also Range("G2").value for Enddate.