VBA to add Pivot Table filters looks different from manually adding filters

CodeNewb

New Member
Joined
Aug 29, 2013
Messages
23
I'm trying to make a pivot table with a few filters, and make it look the way it looks when people do it manually, but the appearance is completely different. I recorded a macro when inserting the filter fields, and the VBA code is precisely the same, but the look of the result is completely different. I'm sure there must be some layout/design thing that is a default but when I look at every property I'm aware of for a new pivot table, including table design, none of them give me my desired result. Please see the attached screen shots. One is named "ManualPivot" (this is where fields are dragged from pivot table list down to the Filters box) and MacroPivot (this is when adding the fields via VBA code, shown below. This code is also identical to what's created when recording a macro dragging the fields into Filters box of pivot table design).


VBA Code:
    With PTable2.PivotFields("Sell Date")
        .Orientation = xlPageField
        .Position = 1
    End With
    
    With PTable2.PivotFields("Cust Descrip")
        .Orientation = xlPageField
        .Position = 2
    End With
    
    With PTable2.PivotFields("Fulfilled YN")
        .Orientation = xlPageField
        .Position = 3
    End With

How in VBA can I duplicate the appearance of the manually added filter fields?

Thanks for any help
 

Attachments

  • MacroPivot.jpg
    MacroPivot.jpg
    31 KB · Views: 11
  • ManualPivot.jpg
    ManualPivot.jpg
    22 KB · Views: 11

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

Forum statistics

Threads
1,214,646
Messages
6,120,720
Members
448,986
Latest member
andreguerra

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