ich habe eine Datei bei der ich den Namen für den Pivotbereich umbenennen mußte (sonst Doppelnennung bei Zusammenlegung der Dateien).
Nach dem ich alle Datenquellen geändert hatte, war die Datei 5x so groß.
Jetzt wollte ich die Quellen angleichen.
Habe z.B. dieses Makro gefunden:
Sub ALL_PIVOTS_SAME_CACHE()
Dim wb As Workbook
Dim vSheet As Worksheet
Dim vCell As Range
Dim pvtTable As PivotTable
Dim pvtCache As PivotCache
Dim vPivotCache As PivotCache
Dim pvtField As PivotField
Dim pvtItem As PivotItem
Dim i As Integer
Dim bVisible
Dim bProtected
Dim v
" PRÜFE MULTIUSER
" Protect ist unter freigabemodus nicht möglich
On Error Resume Next
If ActiveWorkbook.MultiUserEditing = True Then
ActiveWorkbook.ExclusiveAccess
End If
"INIT
On Error GoTo 0
Set wb = ActiveWorkbook
Set vSheet = ActiveWorkbook.ActiveSheet
Set vCell = ActiveCell
"Set pvtTable = vCell.PivotTable
"Set vPivotCache = pvtTable.PivotCache
"loop durch Blaetter
For Each vPivotCache In wb.PivotCaches
v = wb.PivotCaches.Count
Next
"MsgBox "fertig"
"Exit Sub
For Each vSheet In ActiveWorkbook.Worksheets
bVisible = vSheet.Visible
If bVisible xlSheetVisible Then vSheet.Visible = xlSheetVisible
bProtected = vSheet.ProtectContents
If bProtected False Then vSheet.Unprotect pwAlt: vSheet.Unprotect pw
vSheet.Activate
v = wb.PivotCaches.Count
For Each pvtTable In vSheet.PivotTables
pvtTable.PivotCache.OptimizeCache = True
pvtTable.PivotCache.Connection = vPivotCache.Connection
pvtTable.PivotCache.Refresh
Next
If bProtected False Then
vSheet.Protect Password:=pw, Contents:=True, UserInterfaceOnly:=True, _
AllowFormattingColumns:=True, AllowFormattingRows:=True
vSheet.EnableOutlining = True
vSheet.EnableAutoFilter = True
End If
If bVisible = False Then vSheet.Visible = bVisible
Next
"SCAN PIVOT
MsgBox "Fertig"
End Sub
Da steigt er bei mir aber total aus und alles ist in VBA rot.Weiß jemand Rat?
Vielen Dank, Gruß Jens