Djblois
08-22-2006, 08:59 AM
here is my code:
Dim pvt1 As Worksheet
Dim ptCache As PivotCache
Dim pt As PivotTable
Dim pRange As Range
Dim finalRow As Long
Set detail = Worksheets("detail")
'Create sheet
Set pvt1 = Worksheets.Add
'Create Cust-Prod Pivot table by month
finalRow = detail.Cells(65536, 1).End(xlUp).Row
Set pRange = detail.Cells(1, 1).Resize(finalRow, 20)
Set ptCache = ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, _
SourceData:=pRange.Address)
Set pt = ptCache.CreatePivotTable(TableDestination:=pvt1.Range("A1"), _
TableName:="CustProd")
I am getting an error on the last line of code saying "Method 'CreatePivot Table' of object 'PivotCache' failed. Does anybody know what the error is?
Dim pvt1 As Worksheet
Dim ptCache As PivotCache
Dim pt As PivotTable
Dim pRange As Range
Dim finalRow As Long
Set detail = Worksheets("detail")
'Create sheet
Set pvt1 = Worksheets.Add
'Create Cust-Prod Pivot table by month
finalRow = detail.Cells(65536, 1).End(xlUp).Row
Set pRange = detail.Cells(1, 1).Resize(finalRow, 20)
Set ptCache = ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, _
SourceData:=pRange.Address)
Set pt = ptCache.CreatePivotTable(TableDestination:=pvt1.Range("A1"), _
TableName:="CustProd")
I am getting an error on the last line of code saying "Method 'CreatePivot Table' of object 'PivotCache' failed. Does anybody know what the error is?