JKwan
09-11-2007, 08:58 AM
I am trying to create a Pivot Table using VBA and I am getting a blank Pivot Table. I don't know why. If I were to create it manually, works great, I do see data in the table. Maybe someone can point me to the right direction.
Set ptTable = wsSheet.PivotTables.Add( _
PivotCache:=ptCache, _
TableDestination:=wsSheet.Range("A4"), _
TableName:="PT_ADO")
'Manipulate some of the pivottable's properties.
With ptTable
.AddFields PageFields:="FIELD_OFFICE_CD"
.AddFields ColumnFields:=Array("LICENSE_NUMBER", "LINE_NUMBER")
.PivotFields("FIELD_OFFICE_CD").Orientation = xlPageField
' .PivotFields("LICENSE_NUMBER").Orientation = xlColumnField
' .PivotFields("LINE_NUMBER").Orientation = xlColumnField
' .Format xlTable2
End With
The above is the core of it. When the VBA excutes, my Table is created, but it is a blank, now, if I click on the drop down box of the pivot field, I see my data????
Thanks
Set ptTable = wsSheet.PivotTables.Add( _
PivotCache:=ptCache, _
TableDestination:=wsSheet.Range("A4"), _
TableName:="PT_ADO")
'Manipulate some of the pivottable's properties.
With ptTable
.AddFields PageFields:="FIELD_OFFICE_CD"
.AddFields ColumnFields:=Array("LICENSE_NUMBER", "LINE_NUMBER")
.PivotFields("FIELD_OFFICE_CD").Orientation = xlPageField
' .PivotFields("LICENSE_NUMBER").Orientation = xlColumnField
' .PivotFields("LINE_NUMBER").Orientation = xlColumnField
' .Format xlTable2
End With
The above is the core of it. When the VBA excutes, my Table is created, but it is a blank, now, if I click on the drop down box of the pivot field, I see my data????
Thanks