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

CodeNewb

New Member
Joined
Aug 29, 2013
Messages
18
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: 10
  • ManualPivot.jpg
    ManualPivot.jpg
    22 KB · Views: 10

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,114
Messages
5,835,462
Members
430,358
Latest member
zzc1128

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
Top