Hallo!
habe folgenden COde und bekomme den Laufzeitfehler 1004 an der markierten Stelle:
Sub CreatePivottables()
Dim ptCache As PivotCache
Dim ptTable As PivotTable
Dim i As Integer
With ActiveSheet
For Each ptTable In .PivotTables
ptTable.TableRange2.Delete
Next ptTable
End With
Set ptCache = ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:=ActiveSheet.UsedRange.Address)
Set ptTable = ptCache.CreatePivotTable(TableDestination:="", TableName:="PivotTable1")
With ptTable
.PivotFields("Basis_for_Reports.Fondsname").Orientation = xlPageField
.PivotFields("Channel").Orientation = xlPageField
.PivotFields("Country").Orientation = xlPageField
.PivotFields("Basis_for_Reports.Retail/Institutional").Orientation = xlPageField
.PivotFields("Basis_for_Reports.Region").Orientation = xlPageField
.PivotFields("ValidDate").Orientation = xlPageField
.PivotFields("Clients_for_Analysis").Orientation = xlRowField
.PivotFields("AUM").Orientation = xlDataField
.PivotFields("netflows_mtd").Orientation = xlDataField
.PivotFields("netflows_ytd").Orientation = xlDataField
End With
With ptTable
With .PivotFields("Clients_for_Analysis")
With .LabelRange
.Interior.ColorIndex = 5
.Font.Bold = True
End With
With .DataRange
.Interior.ColorIndex = 34
End With
End With
With .PivotFields("AUM")
With .LabelRange
.Interior.ColorIndex = 3
.Font.Bold = True
End With
With .DataRange
Interior.ColorIndex = 38
End With
End With
End With
With ActiveSheet.PivotTables("PivotTable1").DataPivotField
.Orientation = xlColumnField
.Position = 1
End With
Cells.Replace What:="Summe von", Replacement:=" ", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Columns("A:N").AutoFit
Set ptCache = Nothing
Set ptTable = Nothing
End Sub
Wie kann ich das Problem beheben?
habe folgenden COde und bekomme den Laufzeitfehler 1004 an der markierten Stelle:
Sub CreatePivottables()
Dim ptCache As PivotCache
Dim ptTable As PivotTable
Dim i As Integer
With ActiveSheet
For Each ptTable In .PivotTables
ptTable.TableRange2.Delete
Next ptTable
End With
Set ptCache = ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:=ActiveSheet.UsedRange.Address)
Set ptTable = ptCache.CreatePivotTable(TableDestination:="", TableName:="PivotTable1")
With ptTable
.PivotFields("Basis_for_Reports.Fondsname").Orientation = xlPageField
.PivotFields("Channel").Orientation = xlPageField
.PivotFields("Country").Orientation = xlPageField
.PivotFields("Basis_for_Reports.Retail/Institutional").Orientation = xlPageField
.PivotFields("Basis_for_Reports.Region").Orientation = xlPageField
.PivotFields("ValidDate").Orientation = xlPageField
.PivotFields("Clients_for_Analysis").Orientation = xlRowField
.PivotFields("AUM").Orientation = xlDataField
.PivotFields("netflows_mtd").Orientation = xlDataField
.PivotFields("netflows_ytd").Orientation = xlDataField
End With
With ptTable
With .PivotFields("Clients_for_Analysis")
With .LabelRange
.Interior.ColorIndex = 5
.Font.Bold = True
End With
With .DataRange
.Interior.ColorIndex = 34
End With
End With
With .PivotFields("AUM")
With .LabelRange
.Interior.ColorIndex = 3
.Font.Bold = True
End With
With .DataRange
Interior.ColorIndex = 38
End With
End With
End With
With ActiveSheet.PivotTables("PivotTable1").DataPivotField
.Orientation = xlColumnField
.Position = 1
End With
Cells.Replace What:="Summe von", Replacement:=" ", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Columns("A:N").AutoFit
Set ptCache = Nothing
Set ptTable = Nothing
End Sub
Wie kann ich das Problem beheben?