From: OldDog on
I have created a sub that builds a Pivot Table in an Excel
spreadsheet. The problem I am having is that the Column headers are
not being set.

Here is the Sub:

Sub Pivot
' Pivot Table Macro
'
Const xlPivotTableVersion10 = 1
Const xlDatabase = 1
Const xlRowField = 1
Const xlColumnField = 2
Const xlCount = -4112
'
wb2.PivotCaches.Create(xlDatabase,"Report!
R1C1:R65536C11",xlPivotTableVersion10).CreatePivotTable _
"Sheet3!R1C1","PivotTable1",xlPivotTableVersion10
ws3.Select
ws3.Cells(1, 1).Select
With ws3.PivotTables("PivotTable1").PivotFields("Server")
.Orientation = xlRowField
.Position = 1
End With
With ws3.PivotTables("PivotTable1").PivotFields("KB#") '<--- this
is not working
.Orientation = xlColumnField
.Position = 1
End With
ws3.PivotTables("PivotTable1").AddDataField ws3.PivotTables( _
"PivotTable1").PivotFields("KB#"),"Count of KB#", xlCount ' Or
maybe this?

End Sub
<--------------- End Code --------------- >

I started out by creating a Macro in excel and then modifying it for
vbScript. The Pivot table is created but the Columns are not labeld.

I have two columns ; Column A (1) is my server names and Column D (4)
is KB#. I want a count of each KB for each server.

TIA