Help with VBA createpivottable code!!!

aallaman

New Member
Joined
Dec 4, 2009
Messages
44
Hi Everyone,

I am working with the code below but am getting an "Invaild procedure call or argument" error on the code in red.

I have tried everything I know with no luck. Can anyone help?????

Thanks

Allen



Sub ErrorReportingCreatePivotTableTake1()
'
' ErrorReportingCreatePivotTableTake1 Macro
'
'

Dim WSD As Worksheet
Dim PTCache As PivotCache
Dim PT As PivotTable
Dim PRange As Range
Dim FinalRow As Long
Set WSD = Worksheets("Error_Reporting")

' Define input area and set up a Pivot Cache

FinalRow = WSD.Cells(Application.Rows.Count, 1).End(xlUp).Row
FinalCol = WSD.Cells(1, Application.Columns.Count). _
End(xlToLeft).Column
Set PRange = WSD.Cells(1, 1).Resize(FinalRow, FinalCol)
Set PTCache = ActiveWorkbook.PivotCaches.Add(SourceType:= _
xlDatabase, SourceData:=PRange.Address)

' Create the Pivot Table from the Pivot Cache

Sheets.Add
Set PT = PTCache.CreatePivotTable(TableDestination:="Sheet10!R3C1", TableName:="PivotTable3", _
DefaultVersion:=xlPivotTableVersion14)


End Sub
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
does that sheet name (sheet10) exist in your workbook?
Have you tried to manual create the pivot table with the same?
 
Upvote 0
Hey texasalynn

The sheet name was just an example, but using the actual sheet name didn't work either. I found a workaround whereI defined the target sheet name as a variable and I also had to take off the defaultformat variable. Once I did those two things it worked ok.

I have another question about using a conditional pivot filter if you can help out. http://www.mrexcel.com/forum/showthread.php?p=2668092#post2668092

Thanks!

Allen
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,712
Members
452,939
Latest member
WCrawford

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