Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Pivot table calculated field
I have two macros below, to one to create and the other to delete calculated
field. When I run create, the macro completes successfully. When I run the latter I get an error message "Method 'Delete' of object 'PivotField' failed. Can you please help me amend the 'DeleteCalcFields_Click() macro. Private Sub DeleteCalcFields_Click() For Each fld In _ Worksheets("Create calc fields").PivotTables("PivotTable1").CalculatedFiel ds fld.Delete Next End Sub Private Sub CreateCalcFields_Click() Dim rngItems As Range Dim ws As Worksheet Dim pt As PivotTable Dim c As Range Dim pf As PivotField Set ws = Worksheets("Create calc fields") Set pt = ws.PivotTables("PivotTable1") Set rngItems = ws.Range("AddItems") For Each c In rngItems On Error Resume Next Set pf = ws.PivotTables("PivotTable1").CalculatedFields(c.V alue) On Error GoTo 0 If Not pf Is Nothing Then ws.PivotTables("PivotTable1").CalculatedFields(c.V alue) _ .StandardFormula = c.Offset(0, 1).Value Else ws.PivotTables("PivotTable1").CalculatedFields.Add _ c.Value, c.Offset(0, 1).Value, True ' pt.PivotFields(c.Value).Orientation = xlDataField End If Next c End Sub |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Pivot table calculated field
Add:
Dim fld As PivotField |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Pivot table calculated field
"Herbert Seidenberg" wrote: Add: Dim fld As PivotField Herbert. Thanks for your suggestion, but unfortunately it did not solve the problem. |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
Pivot table calculated field
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Calculated Field and Calculated Item in Pivot Table | Excel Discussion (Misc queries) | |||
pivot table calculated field | Excel Worksheet Functions | |||
pivot table formulas for calculated field or calculated item | Excel Discussion (Misc queries) | |||
Calculated field in Pivot Table | Excel Discussion (Misc queries) | |||
Calculated Field in Pivot Table | Excel Worksheet Functions |