Need VBA pivot tables help

Need_Help_Now

New Member
Joined
Sep 25, 2009
Messages
6
Hi everyone, I am trying to make pivot tables by recording macros but always get this "run time error '5' Invalid procedure call or argument". It recorded it fine but doesn't work when I try and re-run it!

Anyway here is the code can you please help!? Thanks.

ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"sheet1!R1C1:R1533C22", Version:=xlPivotTableVersion10). _
CreatePivotTable TableDestination:="Sheet2!R1C1", TableName:= _
"PivotTable1", DefaultVersion:=xlPivotTableVersion10
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
If you run that macro repeatedly, you are trying to create another pivot table in the same place as the first and with the same name. Could you elaborate on what you are actually hoping the macro will do?
 
Upvote 0
I am creating a report for someone who has no idea about excel or macros that will update information evertime they open up the sheet.

The reason I'm replacing the pivot table rather than refreshing is because just refreshing mixes up the variables for reasons I can't understand and the only way to update the data with the variables in the right place is to create a new pivot table.

Thanks for your help.
 
Upvote 0
Looking at the code again, if you get an error 5 (rather than 1004) I suspect you either don't have a sheet called Sheet2 or you don't have Sheet1.
 
Upvote 0

Forum statistics

Threads
1,215,491
Messages
6,125,111
Members
449,205
Latest member
ralemanygarcia

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