I have some basic code (see below) that is inserting a pivot table. Sitecode is in the row labels, and then I have Count of WO and SUM of Sales in the "values" section.
When I execute the code manually, it comes out the way I like, but when I run it through our systems, it's putting the "VALUES" in the row labels rather than the column labels (see picture). How can I fix this? This is the first time I've run into this issue. I don't recall ever doing an "Orientation" on values. Thanks!
https://docs.google.com/file/d/0B0PZQ2m9_AniNkZFby1yZjlsUGs/edit?usp=sharing
When I execute the code manually, it comes out the way I like, but when I run it through our systems, it's putting the "VALUES" in the row labels rather than the column labels (see picture). How can I fix this? This is the first time I've run into this issue. I don't recall ever doing an "Orientation" on values. Thanks!
https://docs.google.com/file/d/0B0PZQ2m9_AniNkZFby1yZjlsUGs/edit?usp=sharing
Code:
Sheets.Add
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"Query NO 758!R1C1:R15000C30", Version:=xlPivotTableVersion10). _
CreatePivotTable TableDestination:="sheet2!R3C1", TableName:="PivotTable1" _
, DefaultVersion:=xlPivotTableVersion10
Sheets("sheet2").Select
Cells(3, 1).Select
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Site #")
.Orientation = xlRowField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Order sub type")
.Orientation = xlRowField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("WO"), "Count of WO", xlCount
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("SALES_AMOUNT"), "Sum of SALES_AMOUNT", xlSum