Method 'Create' of object 'PivotCaches' failed

lakshmipathi123

Board Regular
Joined
Jul 10, 2012
Messages
52
Office Version
  1. 365
Platform
  1. Windows
Hi Experts,

I have an error while creating an pivot. Please see below code and let me know error.

Sub Pivot()
'
' Macro1 Macro
'
Dim MyRange As Range

Sheets("Pivot - Recon").Select
Cells.Select
Selection.Delete Shift:=xlUp

Sheets("Main").Select
Range("A6").Select
Set MyRange = ActiveCell.CurrentRegion

ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:=MyRange, Version:=xlPivotTableVersion15).CreatePivotTable _
TableDestination:="'[UFAR Macro Ver 1.0.xlsm]Pivot - Recon'!R1C1", TableName:= _
"Pivot", DefaultVersion:=xlPivotTableVersion15


ActiveSheet.PivotTables("Pivot").AddDataField ActiveSheet.PivotTables( _
"Pivot Recon").PivotFields("Cost"), "Sum of Cost", xlSum

ActiveSheet.PivotTables("Pivot").AddDataField ActiveSheet.PivotTables( _
"Pivot Recon").PivotFields("Ltd Depr"), "Sum of Ltd Depr", xlSum

With ActiveSheet.PivotTables("Pivot").PivotFields("Category")
.Orientation = xlRowField
.Position = 1
End With

With ActiveSheet.PivotTables("Pivot").PivotFields("Sub Category")
.Orientation = xlRowField
.Position = 2
End With

With ActiveSheet.PivotTables("Pivot").PivotFields("BU")
.Orientation = xlRowField
.Position = 3
End With

Columns("B:C").Select
Selection.NumberFormat = "#,##0.00_);(#,##0.00)"
Cells.Select
Columns.AutoFit

End Sub

Thank you,
Lakshmipathi
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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