• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

PivotTable Date Range on Row Fields

mistryman

New Member
Hey Guys

The code below keeps telling me that the date I entered is not a valid date. I checked the cells and everything matches up. Anyone have an idea of what might be wrong.

Code:
Sub Macro1()
'
' Macro1 Macro
'
Dim dtStart As Date, dtEnd As Date
  
  With Worksheets("Pivot")
  dtStart = Range("E1")
  dtEnd = Range("F1")
  
  With .PivotTables("MatDataPvt").PivotFields("MaturityDate")
  .ClearAllFilters
  .PivotFilters.Add Type:=xlDateBetween, _
  Value1:=dtStart, Value2:=dtEnd
  End With
  
  End With

End Sub
 
Back
Top