Problem creating pivot table

Steve48

New Member
Joined
Apr 11, 2009
Messages
11
I recorded macro shown below. But when I run it I get error on 1st line: invalid procedure call or argument.

Code:
Sub pivot()
'
' pivot Macro
'
'
    ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
        "Concatenate-2!R2C21:R7125C26", Version:=xlPivotTableVersion12). _
        CreatePivotTable TableDestination:="Pivot-2!R1C1", TableName:="PivotTable1" _
        , DefaultVersion:=xlPivotTableVersion12
    Sheets("Pivot-2").Select
    Cells(1, 1).Select
    Range("A18").Select
    With ActiveSheet.PivotTables("PivotTable1").PivotFields( _
        "Concatenate Campaign & Ad Group")
        .Orientation = xlRowField
        .Position = 1
    End With
    ActiveSheet.PivotTables("PivotTable6").AddDataField ActiveSheet.PivotTables( _
        "PivotTable1").PivotFields("Clicks"), "Sum of Clicks", xlSum
    ActiveSheet.PivotTables("PivotTable6").AddDataField ActiveSheet.PivotTables( _
        "PivotTable1").PivotFields("Impressions"), "Sum of Impressions", xlSum
    ActiveSheet.PivotTables("PivotTable6").AddDataField ActiveSheet.PivotTables( _
        "PivotTable1").PivotFields("Cost"), "Sum of Cost", xlSum
    ActiveSheet.PivotTables("PivotTable6").AddDataField ActiveSheet.PivotTables( _
        "PivotTable1").PivotFields("Avg. position"), "Sum of Avg. position", xlSum
    ActiveSheet.PivotTables("PivotTable6").AddDataField ActiveSheet.PivotTables( _
        "PivotTable1").PivotFields("Cost / conv. (1-per-click)"), _
        "Sum of Cost / conv. (1-per-click)", xlSum
End Sub
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Forum statistics

Threads
1,203,071
Messages
6,053,369
Members
444,658
Latest member
lhollingsworth

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