Values are shift to Row Labels for some reason

bcurrey

Board Regular
Joined
Aug 11, 2011
Messages
110
Office Version
  1. 365
Platform
  1. MacOS
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



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
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Any ideas? I've still not been able to figure it out. Thanks.
 
Upvote 0

Forum statistics

Threads
1,215,639
Messages
6,125,967
Members
449,276
Latest member
surendra75

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top