title: CalculatedField in Excel
body: <p>Let's assume I have two columns in excel, dates as rows and I want to create a pivot table with some calculated field. Formula for calculated field is <code>Column1 / AVERAGE(Column2)</code>, depending on dates selected.</p>
  
  <p>I use vba. but when I do </p>
  
  <pre><code>pvtTable.CalculatedFields.Add Name:="Test1", Formula:="Column1 / AVERAGE(Column2)"
  </code></pre>
  
  <p><del><code>AVERAGE</code> is being count from sum of values in column 2 (for selected date range), not single values. </del>
  <strong>EDIT</strong>: <code>AVERAGE</code> seems to be ignored in calculated field's formula and sum is taken instead.</p>
  
  <p>Is there any way to use single values when using <code>AVERAGE</code> in calculated field's formula? I use Office 2010.</p>
  
  <p><strong>More details</strong></p>
  
  <p>I tried to do this:</p>
  
  <pre><code>With pvtTable
      With .PivotFields("Column2")
          .Orientation = xlDataField
          .Function = xlAverage
          .NumberFormat = "0.00"
          .Value = "Avg Column2"
      End With
  End With
  pvtTable.CalculatedFields.Add Name:="Test2", Formula:="Column1 / Avg Column2"
  </code></pre>
  
  <p>But <code>Test2</code> isn't shown on the pivot table's field list. When I want to display it from vba, I get an error <code>Unable to get the PivotFields property of the PivotTable class</code>.</p>