Pivot in a Macro-- debugging help needed

harry4u9

New Member
Joined
Feb 13, 2012
Messages
12
Have recorded the following macro but it is asking me to debug it & I cant understand what is going wrong.. pls help


Code:
    Sheets("Pivot").Visible = True
    Application.Goto Reference:="'RPA Readiness'!R1C1"
    Application.Goto Reference:="Pivot!R1C1"
    ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
        "'Process Map'!R9C1:R1501C7", Version:=xlPivotTableVersion15). _
        CreatePivotTable TableDestination:="[RPA_Diagnostic.xlsm]Pivot!R3C1", _
        TableName:="PivotTable11", DefaultVersion:=xlPivotTableVersion15
    With ActiveSheet.PivotTables("PivotTable11").PivotFields("Process L1")
        .Orientation = xlRowField
        .Position = 1
    End With
    With ActiveSheet.PivotTables("PivotTable11").PivotFields("Process L2")
        .Orientation = xlRowField
        .Position = 2
    End With
    With ActiveSheet.PivotTables("PivotTable11").PivotFields("Process L3")
        .Orientation = xlRowField
        .Position = 3
    End With
    ActiveSheet.PivotTables("PivotTable11").AddDataField ActiveSheet.PivotTables( _
        "PivotTable11").PivotFields("% Probablity of Automation"), _
        "Count of % Probablity of Automation", xlCount
    With ActiveSheet.PivotTables("PivotTable11").PivotFields( _
        "Count of % Probablity of Automation")
        .Caption = "Average of % Probablity of Automation"
        .Function = xlAverage
    End With
    ActiveSheet.PivotTables("PivotTable11").PivotFields("Process L1").Subtotals = _
        Array(False, False, False, False, False, False, False, False, False, False, False, False)
    ActiveSheet.PivotTables("PivotTable11").PivotFields("Process L2").Subtotals = _
        Array(False, False, False, False, False, False, False, False, False, False, False, False)
    ActiveSheet.PivotTables("PivotTable11").PivotFields("Process L3").Subtotals = _
        Array(False, False, False, False, False, False, False, False, False, False, False, False)
    ActiveSheet.PivotTables("PivotTable11").PivotFields("Process L4").Subtotals = _
        Array(False, False, False, False, False, False, False, False, False, False, False, False)
    ActiveSheet.PivotTables("PivotTable11").PivotFields("Process L5").Subtotals = _
        Array(False, False, False, False, False, False, False, False, False, False, False, False)
    ActiveSheet.PivotTables("PivotTable11").PivotFields( _
        "Diagnostic Completion Check").Subtotals = Array(False, False, False, False, False, _
        False, False, False, False, False, False, False)
    ActiveSheet.PivotTables("PivotTable11").PivotFields( _
        "% Probablity of Automation").Subtotals = Array(False, False, False, False, False, _
        False, False, False, False, False, False, False)
    With ActiveSheet.PivotTables("PivotTable11")
        .ColumnGrand = False
        .RowGrand = False
    End With
    ActiveSheet.PivotTables("PivotTable11").RowAxisLayout xlTabularRow
    ActiveSheet.PivotTables("PivotTable11").RepeatAllLabels xlRepeatLabels
    With ActiveSheet.PivotTables("PivotTable11").PivotFields("Process L1")
        .PivotItems("(blank)").Visible = False
    End With
    Application.Goto Reference:="Pivot!R1C1"
    Cells.Select
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.Goto Reference:="Pivot!R3C1"
    Range(Selection, Selection.End(xlToRight)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Application.CutCopyMode = False
    ActiveWorkbook.Worksheets("Pivot").Sort.SortFields.Clear
    ActiveWorkbook.Worksheets("Pivot").Sort.SortFields.Add Key:=Range("D4:D1508"), _
        SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
    With ActiveWorkbook.Worksheets("Pivot").Sort
        .SetRange Range("A3:D1508")
        .Header = xlYes
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
 
Last edited:

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
What do you mean? Are you trying to run the macro to build another Pivot table? Have you tried to use F8 on the keyboard from the VBA screen and then you can place in your thread which line it is debugging on.
 
Upvote 0

Forum statistics

Threads
1,215,385
Messages
6,124,626
Members
449,174
Latest member
Anniewonder

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top