"Run-Time Error '1004'

F

Fei

Hi all,

When I run my VBA, there was a message:

"Run-Time Error '1004':

The pivotTable field name is not valid. To create a pivottable report,
you must use data that is organized as a list with labeled columns. If
you are changing the name of a pivottable field, you must type a new
name for the field."

It occurred when running:
Set PTCache = ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, _
SourceData:=PRange.Address)
Set PT = PTCache.CreatePivotTable(TableDestination:=shhet1.Range
("A1"), _
TableName:="PovitTable1")

Any help is appreciated

Fei
 
A

aamerrasheed via OfficeKB.com

Hi,
You can try changing ActiveWorkbook.PivotCaches.Add to ActiveWorkbook.
PivotCaches.Create
 
T

Tim Williams

Hard to tell without seeing the source data, but maybe try one of these...
Did you mean "sheet1" ?
Try just
SourceData:=PRange

Tim
 
F

Fei

Thanks all!

I have tried “create” - but not working.....

Sheet1 is the name of my worksheet, which contains my Pivot table –
“Dim Sheet1=Worksheets(Pivot Table)”. As the table and data are in two
worksheets, i have to specify the sheet name...

Also, after the run-time error 1004, when i continue to run the codes,
there is another error - "run-time error '-2147417848(80010108)":
Method 'CreatePivoteTable' of object 'PivotCache' failed'"....

I followed the sample codes, and the data is normal dataset......not
sure why...

Thanks

Fei
 

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


Top