title: PivotTableWizard - Name of Data Fields as Column Headers
body: <p>I am creating a PivotTable from an Excel Sheet using VBA PivotTableWizard method.</p>
  
  <p>I do define two row fields and two data fields with sum function. By default the name of the data fields appear in the Pivot Table as row description right from the row field names.</p>
  
  <p>I wish to display the name of the data fields as column headers. In the Wizard the user would drag the "Sum sign - Values" field into the Column Labels box. How can this be done by code?</p>
  
  <p>This is what I do have so far:</p>
  
  <pre><code>' Create the PivotTable object based on the data on the selected sheet
  Set tm_volumes_pivot_table = ActiveSheet.PivotTableWizard
  
  
  'Page fields
  Set tm_volumes_pivot_field = tm_volumes_pivot_table.PivotFields("Article Type")
  tm_volumes_pivot_field.Orientation = xlPageField
  
  'Row fields
  Set tm_volumes_pivot_field = tm_volumes_pivot_table.PivotFields("Main Area")
  tm_volumes_pivot_field.Orientation = xlRowField
  Set tm_volumes_pivot_field = tm_volumes_pivot_table.PivotFields("Subarea")
  tm_volumes_pivot_field.Orientation = xlRowField
  
  
  'Column fields
  'Must be Names of Data Fields - how?
  
  
  'Data fields
  Set tm_volumes_pivot_field = tm_volumes_pivot_table.PivotFields("Initial Volume")
  tm_volumes_pivot_field.Orientation = xlDataField
  tm_volumes_pivot_field.Function = xlSum
  tm_volumes_pivot_field.NumberFormat = "#"
  
  Set tm_volumes_pivot_field = tm_volumes_pivot_table.PivotFields("Final Volume")
  tm_volumes_pivot_field.Orientation = xlDataField
  tm_volumes_pivot_field.Function = xlSum
  tm_volumes_pivot_field.NumberFormat = "#"
  </code></pre>