Need help adding a pivot table to a new sheet using vba

frank1107

New Member
Joined
Jan 13, 2015
Messages
2
Hey all, I attempted to use record macro to record my steps to use at a later time. I got to the step of adding a pivot table to a new sheet before i received an error. I assume dit was because the sheet the pivot table was attempting to be added to already existed. I tried to use online sources to modify the code to create a new sheet to add the pivot table but still receive an error at this part of the code:

ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"OmniPort!R1C1:R3405C16", Version:=xlPivotTableVersion10).CreatePivotTable _
TableDestination:=wsNew.Name & "!R1C16", TableName:="newPivotTable1", DefaultVersion _
:=xlnewPivotTableVersion10

Any idea why the error is still happening?

Thanks for the help.
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Hi frank1107,

An argument used for DefaultVersion seems to be xlPivotTableVersion10. No need to add "new" I guess.
 
Upvote 0
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"OmniPort!R1C1:R3405C16", Version:=xlPivotTableVersion10).CreatePivotTable _
TableDestination:=wsNew.Name & "!R1C16", TableName:="PivotTable1", DefaultVersion _
:=xlPivotTableVersion10

deleted the "new" but still receiving the same error at the same point.

Thanks for the idea though!
 
Upvote 0

Forum statistics

Threads
1,214,990
Messages
6,122,625
Members
449,093
Latest member
catterz66

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