title: Excel Pivot Table issue setting a column to "Running Total" using VBA
body: <p>I am using VBA to loop through pivot tables in order to update the values to include new data (from external source) and to update the start and end dates for the groupings. This code works...</p>
  
  <pre><code>For Each pvt In ws.PivotTables
  
      For Each pvtFld In pvt.RowFields
          rowLabel = pvtFld.Name
          pvtFld.DataRange.Group Start:=startDate, End:=endDate, By:=7, Periods:=Array(False, False, False, True, False, False, False)
      Next pvtFld ...
  
  [Trouble code will go here, but let me explain further]
  
  Next pvt
  </code></pre>
  
  <p>The problem that I am encountering is that upon refresh all of the "running totals" are reset to "no calculation.  </p>
  
  <p>Recording a macro is helpful but not useful for other spreadsheets</p>
  
  <pre><code>' Sets the "Total" Column from each Pivot to "Running Total"
  With ws.PivotTables("LOEPivot").PivotFields( _
      "Total Planned LOE")
      .Calculation = xlRunningTotal
      .BaseField = "MOI"
  End With
  </code></pre>
  
  <p>So, I tried to embed another <code>For each</code> like this...</p>
  
  <pre><code>For each pvtCol in pvt.ColumnFields
      if pvtCol.Name Like .Name &amp; "Total" Then
         pvtCol.Calculation = xlRunningTotal
      end if 
  Next pvtCol
  </code></pre>
  
  <p>This doesn't work though b/c the Column Names equal the string "Values"</p>
  
  <p>Is there a different method or property that I am missing?</p>