http://support.microsoft.com/kb/318063
http://social.msdn.microsoft.com/Forums/en-US/isvvba/thread/60fa78ed-0913-4bf5-9c47-2bc0eea59a2c
For Each pf In pt.PivotFields
If pf <> "a" And pf <> "b" And pf.Orientation <> xlHidden Then
Debug.Print pf
pf.Orientation = xlHidden
End If
Next pf
For Each pf In pt.DataFields
Debug.Print pf
Debug.Print pf.Orientation
Next pf
Set pf = pt.DataFields("Sum of e")
For Each pi In pf.PivotItems
pi.Visible = False
Next pi
For Each pf In pt.DataFields
Debug.Print pf.SourceName
Next pf
For Each pf In pt.PivotFields
If pf <> "a" And pf <> "b" And pf.Orientation <> xlHidden Then
Debug.Print pf
pf.Orientation = xlHidden
End If
Next pf
For Each pf In pt.DataFields
Debug.Print pf
pf.Orientation = xlHidden
Next pf
Sub RemoveCalculatedFields()
Dim pt As PivotTable
Dim pf As PivotField
Dim pfNew As PivotField
Dim strSource As String
Dim strFormula As String
Set pt = ActiveSheet.PivotTables(1)
For Each pf In pt.CalculatedFields
strSource = pf.SourceName
strFormula = pf.Formula
pf.Delete
Set pfNew = pt.CalculatedFields.Add(strSource, strFormula)
Next pf
End Sub
Option Explicit
Sub test()
Dim pt As PivotTable
Dim pf As PivotField
Dim pfx As PivotField
Dim pi As PivotItem
Dim strSource As String
Dim strFormula As String
Set pt = Worksheets("Sheet4").PivotTables("PivotTable1")
For Each pf In pt.DataFields
If pt.PivotField(pf.SourceName).IsCalculated Then Debug.Print "Assa"
Debug.Print pf
Debug.Print pf.SourceName
strSource = pf.SourceName
Debug.Print strSource
Next pf
Debug.Print pt.p
End Sub
'내 이야기' 카테고리의 다른 글
편한게 좋은건가? (0) | 2012.07.16 |
---|---|
뭐든 몸이 멀어지면 마음도 멀어지나보다. (0) | 2012.07.05 |
요즘들어 많이 약해지는 것 같다. (0) | 2012.06.05 |
야간대학원 3학기 중간고사 2개 종료 (0) | 2012.04.25 |
아이폰 수리점에 다녀왔다. (0) | 2012.04.16 |