Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1084to1088
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Formatierung in Pivot!
Thomas
Hallo Experten!
Ich brauche mal wieder eure Hilfe.
In einer Datei befinden sich ca. 9 verschiedene Pivot-Tabellen. Diese sollen alle die gleiche Formatierung (Rahmen) haben, welche allerdings immer bei der Aktualisierung verschwindet.
Nun wollte ich das ganze per Makro lösen. Leider kommt immer wieder ein Fehler und ich finde den Fehler einfach nicht. Danke für eure Hilfe und Unterstüztung schon vor ab.
Thomas H.

Sub Test()
Dim piv As PivotTable
For Each piv In ActiveSheet.PivotTables
piv.Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = 1
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = 1
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = 1
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = 1
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = 1
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = 1
End With
Next
Range("B:E,G:J").ColumnWidth = 12
Range("F:F,K:K").ColumnWidth = 8
End Sub


2
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Benutzer
Anzeige
AW: Formatierung in Pivot!
02.07.2009 13:57:09
Helmut
Option Explicit

Sub tt()
Dim i As Long
Dim myPivotTableRange As Range
For i = 1 To ActiveSheet.PivotTables.Count
Set myPivotTableRange = Union(ActiveSheet.PivotTables(i).RowRange, _
ActiveSheet.PivotTables(i).DataBodyRange, _
ActiveSheet.PivotTables(i).ColumnRange, _
ActiveSheet.PivotTables(i).DataLabelRange)
With myPivotTableRange
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
With .Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = 1
End With
With .Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = 1
End With
With .Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = 1
End With
With .Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = 1
End With
With .Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = 1
End With
With .Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = 1
End With
End With
Next i
End Sub



Sub Test()
Dim piv As PivotTable
For Each piv In ActiveSheet.PivotTables
MsgBox ActiveSheet.PivotTables(1).ColumnRange.Address
piv.DataBodyRange.Select
Exit Sub
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = 1
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = 1
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = 1
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = 1
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = 1
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = 1
End With
Next
Range("B:E,G:J").ColumnWidth = 12
Range("F:F,K:K").ColumnWidth = 8
End Sub


Anzeige
Danke Helmut!
02.07.2009 16:03:31
Thomas
lg TH

301 Forumthreads zu ähnlichen Themen

Anzeige
Anzeige
Anzeige

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige