Pivot table and Dates
<p>I am a newbie, and I am sort of a enthusiastic learner, a beginner who is making many mistakes. On my pivot table which is picking up two years worth of dates, I am keen to only choose the first two most recent dates, rather than using a slicer.  I have tried to make it a little bit dynamic, but I am constantly getting error messages, </p>

<p>I was trying to have cells in my spreadsheet which is from date and a two date, or a code that picks the first two most recent dates. I really want the code to work and pulling my hair out, as I have few other pivot tables. Every time I put the cell reference in between, where the dates are I keep getting coding errors.</p>

<p>I want the pivot items more dynamic as like before, I will try to add a validation on the date from and date to make it lot more dynamic. </p>

<p>I want the pivot items to be x first date and y as the second date referring to two cells on the sheet, which I can amend on the sheet, and another code that just picks the first two most recent dates.</p>

<pre><code>Sub DateSlection ()

 With ActiveSheet
.PivotTables("PivotTable4").PivotFields("Date")
        .PivotItems("11/2/2016").Visible = True
        .PivotItems("10/26/2016").Visible = True
    End With
    End Sub
</code></pre>

<p>kind regards </p>

<p>Ali</p>