title: conditional formatting pivot table vba
body: <p>I would like to do some conditional formatting in a pivot table and make sure that when the pivot fields are changed, my formatting stays pertinent to what needs to be formatted. </p>
  
  <p>Here is the beginning: </p>
  
  <p>So far I have 2 columns in my dataset: account# and sales.  Problem I encounter is that my oPvtItm is empty. The "for each" loop is therefore doing nothing.</p>
  
  <pre><code>Sub condformat1()
  
  Dim ws As Worksheet 
  Dim oPvt As PivotTable 
  Dim oPvtItm As PivotItem
  
  Set ws = ActiveSheet 
  Set oPvt = ws.PivotTables("pv1")
  
  
  For Each oPvtItm In oPvt.PivotFields("sum of sales").PivotItems
  
      If oPvtItm &gt; 100000 Then
      oPvtItm.DataRange.Interior.Color = vbYellow
      End If 
  Next
  
  End Sub
  </code></pre>
  
  <p>Once this is solved, I would like to categorise my account (ex. group a,b,c). which might be either a row or column. (lets make it a column to make it simple). I would therefore be willing to analyse only sales of account group "a".  </p>