Hi - Sorry to bother. But this is not working. can you please help.
With your above code, the pivot does not get deleted. This is where i put it
Code:For lngPivots = 1 To 3 With ActiveWorkbook lng = .Worksheets("Output").Cells(Rows.Count, 1).End(xlUp).Row + 2 Set pvt = pvc.CreatePivotTable(TableDestination:="Output!R" & lng & "C1", TableName:="PvtCustom" & lng, DefaultVersion:=xlPivotTableVersion12) End With pvt.AddDataField pvt.PivotFields("Agreement"), "Count of Agreement", xlCount With pvt.PivotFields(Array("MOVE SUMMARY", "COMMENT SUMMARY", "CALL SUMMARY")(lngPivots - 1)) .Orientation = xlRowField .Position = 1 On Error Resume Next .PivotItems("OK").Visible = False .PivotItems("(blank)").Visible = False Err.Clear: On Error GoTo 0: On Error GoTo -1 .Subtotals(1) = False End With With pvt.PivotFields("Counterparty Name") .Orientation = xlRowField .Position = 2 .Subtotals(1) = False End With With pvt .InGridDropZones = True .RowAxisLayout xlTabularRow .TableStyle2 = "PivotStyleMedium8" End With Next lngPivots Application.ScreenUpdating = 1 If pvt.DataBodyRange.Rows.Count < 2 Then pvt.TableRange1.EntireRow.Delete End If




Reply With Quote

Bookmarks