2016-05-18 7 views
0

私はすべての3つのフィールドでピボットを作成しましたが、私は成功し PivotFilters.AddのfilterTypeを使用することはできません。この使用のfilterType:= xlValueIsGreaterThanをエクセル2016でVBA

Name Order Amount Location 
Grace  120000  new jersey 
Tom   200000  baltimore 
Rick  5000000  hyderabad 
Hari  600000  denver 
Raj  4000000  Delhi 
Victoria 300000  New York 

のように見えるのテーブルを持っている:= xlValueIsGreaterThan

オプションが正常に...私のコードに間違っていますか?声明であなたの最後の代わりに

Sub addFields() 
    With ActiveSheet.PivotTables(1) 
'First row field 
    With .PivotFields("Name") 
.Orientation = xlRowField 
.Position = 1 
    End With 

'Report Filter field 
With .PivotFields("Location") 
.Orientation = xlPageField 
    .Position = 1 
    End With 

    'Order Amount or numerical data in the Values field 
    .AddDataField ActiveSheet.PivotTables(1).PivotFields("Order Amount"), _ 
    "Sum of Amount", xlSum 
    End With 


With .PivotFields("Sum of Amount").PivotFilters.Add filterType:=xlValueIsGreaterThan DataField :="Sum of Amount" value1:=4000000 




End With 

    End Sub 

答えて

0

テストこれを

with .PivotFields("Name").PivotFilters.Add2 _ 
    Type:=xlValueIsGreaterThan, DataField:=ActiveSheet.PivotTables(_ 
    "PivotTable1").PivotFields("Sum of Order Amount"), Value1:=4000000