Pivot table error

L

linglc

I have the following codes. It works fine the first time I run it. The next
time I run it there is a error message "Method create pivot table of object
pivotcache failed". It will only work fine if I exit Excel and run the codes
again. Anyone knows why there is a error. The code stops at the "Set PT" row.
FYI, I set PTCache and PT to nothing before I exit the codes.

Set PTCache =
Workbooks("Template.xls").PivotCaches.Add(SourceType:=xlDatabase, _
SourceData:=Range("A1").CurrentRegion.Address)

Set PT = PTCache.CreatePivotTable(TableDestination:="",
TableName:="PivotTable1")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Pivot table in VB 3
Pivot table 1
Pivot Table Creation 2
Pivot Table 1
Pivot table sum data 1
[Microsoft][ODBC Driver Manager] error 3
"Run-Time Error '1004' 2
Pivot Table Macro with dynamic source data 1

Top