ich möchte mehrere Pivot-Tabellen in eine neue Datei kopieren.
Die Datenquellen Bezug soll nicht auf der alten Tabelle sein.
z.B. nicht '\#STATISTIKEN\Rückstandsliste\[Rückstandsliste.xlsb]Rückstandsliste'!$A$5:$AD$5964
aber Rückstandsliste'!$A$5:$AD$5964 sein.
Mit folgende VBA leider funktioniert nicht
Sub CopyRück_TEST()
Application.ScreenUpdating = False
ClearClipboard = True 'Excelinternen Zwischenspeicher löschen
ActiveWorkbook.Save
Dim varFileLog As Variant
Dim intKlammer As Integer
Dim pvtTabelle As PivotTable
Dim strPfad As String
Dim strSource As String
Dim wkbQuelle As Workbook
Dim wkbZiel As Workbook
Dim wksBlatt As Worksheet
varFileLog = "Rück_" & Format(Now, "YYYY.MM.DD hhmmss") & ".xlsx"
Set wkbQuelle = Workbooks("Rückstandsliste.xlsb")
strPfad = wkbQuelle.Path & "\"
wkbQuelle.Sheets(Array("Rückstandsliste", "Pivot", "Oberhaching", "Kunden Pos", "Kunden")).Copy
Set wkbZiel = ActiveWorkbook
Application.DisplayAlerts = False
wkbZiel.SaveAs Filename:=strPfad & varFileLog
Application.DisplayAlerts = False
For Each wksBlatt In wkbZiel.Worksheets
For Each pvtTabelle In wksBlatt.PivotTables
MsgBox pvtTabelle.SourceData
strSource = pvtTabelle.SourceData
If Left(strSource, 1) = "[" Then
intKlammer = InStr(1, strSource, "]", vbTextCompare)
strSource = Mid(strSource, intKlammer + 1)
pvtTabelle.SourceData = strSource
End If
Next pvtTabelle
Next wksBlatt
ActiveWindow.Close
End Sub
kann mir jemand helfen