Goedemorgen,
De onderstaande code heb ik gebruikt om een pivot table te maken.
Echter loopt deze nu vast op:
Set pt = ActiveSheet.PivotTables.Add(PivotCache:=PCache, TableDestination:=Range("C3"), TableName:="PivotTable1")
Wat moet er aangepast worden?
De onderstaande code heb ik gebruikt om een pivot table te maken.
Echter loopt deze nu vast op:
Set pt = ActiveSheet.PivotTables.Add(PivotCache:=PCache, TableDestination:=Range("C3"), TableName:="PivotTable1")
Wat moet er aangepast worden?
Code:
Sub Create_PivotComplaint()
Dim PCache As PivotCache, LastRow As Long, pt As PivotTable
'If "Pivot" worksheet already exists, delete it
On Error Resume Next
Application.DisplayAlerts = False
Sheets("Pivot_Complaints").Delete
On Error GoTo 0
Application.DisplayAlerts = True
Worksheets("Overview Complaints").Activate
Set PCache = ActiveWorkbook.PivotCaches.Create(SourceType:=1, SourceData:=Range("A1").CurrentRegion.Address)
Worksheets.Add
ActiveSheet.Name = "Pivot_Complaints"
ActiveWindow.DisplayGridlines = False
Set pt = ActiveSheet.PivotTables.Add(PivotCache:=PCache, TableDestination:=Range("C3"), TableName:="PivotTable1")