Created
June 30, 2021 10:48
-
-
Save moenk/b4881df5d4e8225a2e0751b997b72cf9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' Quelle definieren | |
Dim wks1, wks2, wks3 As Worksheet | |
Set wks1 = ThisWorkbook.Sheets("Report") | |
Dim tableRange As Range | |
Set tableRange = wks1.UsedRange | |
wks1.ListObjects.Add(SourceType:=xlSrcRange, Source:=tableRange, xlListObjectHasHeaders:=xlYes).Name = "ReportDaten" | |
' Pivot erstellen | |
Dim pc1, pc2 As PivotCache | |
Dim pv1, pv2 As PivotTable | |
Dim rngSrc, rngDst1, rngDst2 As Range | |
Set rngSrc = tableRange | |
Set rngDst1 = wks2.Cells(1, 1) | |
Set rngDst2 = wks3.Cells(1, 1) | |
Set pc1 = ThisWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:=rngSrc.Address) | |
Set pc2 = ThisWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:=rngSrc.Address) | |
Set pv1 = pc1.CreatePivotTable(TableDestination:=rngDst1) | |
Set pv2 = pc2.CreatePivotTable(TableDestination:=rngDst2) | |
pv1.Name = "PivotTable1" | |
pv2.Name = "PivotTable2" | |
' Pivot konfigurieren | |
With pv1.PivotFields("Status") | |
.Orientation = xlRowField | |
End With | |
With pv1.PivotFields("Status") | |
.Orientation = xlDataField | |
End With | |
With pv2.PivotFields("Kategorie") | |
.Orientation = xlRowField | |
.AutoSort Order:=xlAscending, Field:="Ergebnis" | |
End With | |
With pv2.PivotFields("Kategorie") | |
.Orientation = xlDataField | |
End With |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment