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: 5
  • ManualPivot.jpg
    ManualPivot.jpg
    22 KB · Views: 6

Some videos you may like

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

Watch MrExcel Video

Forum statistics

Threads
1,114,443
Messages
5,547,951
Members
410,820
Latest member
Prepost
Top