Hi guys
I would like to write some code to create a pivot table.
the problem is the code that i have seems to cut off some of the data, as i need to use this code on a regular basis this is no good to me.
heres what ive got so far;
Range(Range("b1"), Range("d65536").End(xlUp)).Select
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
"HD!R1C2:R11C4").CreatePivotTable TableDestination:= _
"'[S Template.xls]HD'!R2C7", TableName:="PivotTable3", DefaultVersion:= _
xlPivotTableVersion10
With ActiveSheet.PivotTables("PivotTable3").PivotFields("COMPANY")
.Orientation = xlRowField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable3").PivotFields("CODE")
.Orientation = xlRowField
.Position = 2
End With
ActiveSheet.PivotTables("PivotTable3").AddDataField ActiveSheet.PivotTables( _
"PivotTable3").PivotFields("QTY"), "Sum of QTY", xlSum
Any ideas?
Thanks
I would like to write some code to create a pivot table.
the problem is the code that i have seems to cut off some of the data, as i need to use this code on a regular basis this is no good to me.
heres what ive got so far;
Range(Range("b1"), Range("d65536").End(xlUp)).Select
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
"HD!R1C2:R11C4").CreatePivotTable TableDestination:= _
"'[S Template.xls]HD'!R2C7", TableName:="PivotTable3", DefaultVersion:= _
xlPivotTableVersion10
With ActiveSheet.PivotTables("PivotTable3").PivotFields("COMPANY")
.Orientation = xlRowField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable3").PivotFields("CODE")
.Orientation = xlRowField
.Position = 2
End With
ActiveSheet.PivotTables("PivotTable3").AddDataField ActiveSheet.PivotTables( _
"PivotTable3").PivotFields("QTY"), "Sum of QTY", xlSum
Any ideas?
Thanks