I'm having an error when I specify the table destination.
Here is my code:
When I have TableDestination="", the code works fine.
I'm confused because I'm actually creating that sheet in the code right before creating the pivot table.
Here is my code:
Code:
Worksheets.Add After:=Worksheets(Worksheets.Count)
Worksheets(Worksheets.Count).Name = "Pivot Table"
Worksheets("Pivot Table Data").Activate
Range("A1").CurrentRegion.Name = "PivotRange"
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, _
SourceData:="=PivotRange").CreatePivotTable TableDestination:="Pivot Table!R3C1", TableName:="PivotTable"
When I have TableDestination="", the code works fine.
I'm confused because I'm actually creating that sheet in the code right before creating the pivot table.