2017-02-28 5 views
-1
Sub Pivot_change() 

ActiveSheet.Select 

Cells.Select 

ActiveSheet.protect Password:="SRAS", DrawingObjects:=True, Contents:=True, Scenarios:=True, AllowSorting:=True, AllowFiltering:=True, AllowUsingPivotTables:=True 

Application.ScreenUpdating = False 

Col1 = Cells(10, 1).Value 

Col2 = Cells(10, 2).Value 

ActiveSheet.PivotTables("PivotTable5").PivotFields(Col1).Orientation = xlHidden 

ActiveSheet.PivotTables("PivotTable5").PivotFields(Col2).Orientation = xlHidden 

With ActiveSheet.PivotTables("PivotTable5").PivotFields("CU") 

.Orientation = xlRowField 

.Position = 1 

End With 

With ActiveSheet.PivotTables("PivotTable5").PivotFields("KAM") 

.Orientation = xlRowField 

.Position = 2 

End With 

Application.ScreenUpdating = True 

End Sub 
+1

はあなたのエラーを行を取得しているの? –

答えて

1

を保護するピボットポストの変更中にエラーエン行き方:

Sub Pivot_change() 
Application.ScreenUpdating = False 
With ActiveSheet 
    Col1 = .Cells(10, 1).Value 
    Col2 = .Cells(10, 2).Value 
    With .PivotTables("PivotTable5") 
     .PivotFields(Col1).Orientation = xlHidden 
     .PivotFields(Col2).Orientation = xlHidden 
     With .PivotFields("CU") 
      .Orientation = xlRowField 
      .Position = 1 
     End With '.PivotFields("CU") 
     With .PivotFields("KAM") 
      .Orientation = xlRowField 
      .Position = 2 
     End With '.PivotFields("KAM") 
    End With '.PivotTables("PivotTable5") 
    .Protect Password:="SRAS", DrawingObjects:=True, Contents:=True, Scenarios:=True, AllowSorting:=True, AllowFiltering:=True, AllowUsingPivotTables:=True 
End With 'ActiveSheet 
Application.ScreenUpdating = True 
End Sub 
+0

私は10Kマイルストーンの1つになりたいと思っています –

+0

@ShaiRado:Thx mate! :)))最後にあなたに感謝しました! :) – R3uK

+1

@ShaiRado:うーん...私はmodツールで少し失望しています...:/そこのタグでもフィルタ... – R3uK

関連する問題