title: Mark pivotitems of the fields with some conditions
body: <p>I have few pivotfields and I would like to mark the pivotitems of the fields with some conditions. I have tried using <code>.visible</code> and also have used this <code>application.screenupdating</code> and <code>application.displayfilters</code>. But ist not selecting or deseleting the pivotitems. I would really appreciate each reply.</p>
  
  <p><code>Filter_PivotField_by_Date_Range</code>. This is a function I am calling in my main just to give my field Name and the Dates I want to compare.
  After the 2 if conditions I want it to mark (select/Tickmark) the pivotitems in the field and otherwise unmark/ not select the other ones. Make the other one's invisible and then just Exit Sub.</p>
  
  <p>If you guys have any questions I would really help it to make you all clear. Please any comments or code will be appreciated. </p>
  
  <pre><code>    Sub Filter_PivotField_by_Date_Range(pvtField As PivotField, it1 As Date, it2 As Date)
  
          Dim bTemp As Boolean, i As Long
          Dim dtTemp As Date, dtTemp1 As Date
  
  
          dtTemp = Format(CDate(it1), "dd/mm/yyyy")
          dtTemp1 = Format(CDate(it2), "dd/mm/yyyy")
          On Error Resume Next
  
           With pvtField
            For i = 1 To .PivotItems.Count
  
             dtFrom = .PivotItems(i)
             If (dtTemp &lt;= dtFrom) Then
                 If (dtTemp1 &gt;= dtFrom) Then
                 On Error Resume Next
                         Application.ScreenUpdating = False
                         Application.DisplayAlerts = False
                         .PivotItems(i).Visible = True
                         MsgBox (dtFrom)
                 Else
                    Application.ScreenUpdating = True
                    Application.DisplayAlerts = True
                     Exit Sub
                 End If
  
              End If
            Next i
  
          End With
  
      End Sub
  </code></pre>