2017-02-28 1 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

welche Linie Sie Ihre Fehler zu bekommen? –

Antwort

1

einfach das Blatt nach der Änderung schützen:

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

Ich möchte derjenige sein, der dir einen 10K Meilenstein bringt –

+0

@ShareRado: Thx Kumpel! :))) Endlich hast du es dir dankend gemacht! :) – R3uK

+1

@Shairado: Hmm ... Ich bin ein bisschen enttäuscht in den Mod-Tools, aber ...:/Nicht einmal ein Filter nach Tag drin ... – R3uK

Verwandte Themen