title: Creating a Pivot table with VBScript
body: <p>I am trying to create a pivot table using VBScript. I think I am close to achieving it, but I do not know how to create the report filter and set up the filter for "Internal", or how to use sum instead of count in the values.</p>
  
  <p>That is what I have now:</p>
  
  <pre><code>xlA1 = 1
  xlDatabase = 1
  xlRowField = 1
  xlColumnField = 2
  xlFilterField = 3
  
  Set xlBook1 = objExcel.WorkBooks.Open(ws_path &amp;  "FINAL.xlsx")
  set rngData =xlBook1.Sheets("NONPO").Usedrange
  set rngReport = xlBook1.Sheets("NONPO").Range("CE1")
  
  set pvtCache = xlBook1.pivotCaches.add(xlDatabase, rngData.address(true, true, xlA1, true))
  set pvtTable = pvtCache.createPivotTable(rngReport, "Pivot1")
  
  pvtTable.pivotFields("Date").orientation =xlRowField
  pvtTable.pivotFields("Country Code").orientation = xlColumnField
  pvtTable.pivotFields("Agent Type").orientation =  xlFilterField
   '*****Here I should Use filter as "Internal"*****
  
  pvtTable.pivotFields("Hours").orientation = xlsum  *****xlsum is not working*****
  </code></pre>