Macro to Create Pivot Table

spcalan

Well-known Member
Joined
Jun 4, 2008
Messages
1,247
I built this using the macro recorder, but it is giving me errors.
Here is what i am trying to do:

1. On the "New Round Template" worksheet, create a pivot table of the "Player List" worksheet - Range A2:A100

Seems easy enough... but get an invalid procedure call error.
I am building a pivot table to give the user an ability to select what players he wants ( just trying to create a list ).. I will then just copy/paste special data only to use as a range for another macro...


Sub Create_Players_Pivot()
Sheets("New Round Template").Select
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"Player List!R1C1:R1048576C1", Version:=xlPivotTableVersion12). _
CreatePivotTable TableDestination:="New Round Template!R1C1", TableName:= _
"PivotTable2", DefaultVersion:=xlPivotTableVersion12
Sheets("New Round Template").Select
Cells(1, 1).Select
With ActiveSheet.PivotTables("PivotTable2").PivotFields( _
"Please list all players")
.Orientation = xlRowField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable2").PivotFields( _
"Please list all players")
.PivotItems("(blank)").Visible = False
End With

End Sub
 

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,)

Forum statistics

Threads
1,215,417
Messages
6,124,789
Members
449,188
Latest member
Hoffk036

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