1
votes

This macro has been failing to run due to "Run-time error '1004'"

It states that '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.

The code that needs to be debugged is as follows:

ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
    "Sheet3R1C1:R671905C15", _                                                       
    Version:=xlPivotTableVersion14).CreatePivotTable _
    TableDestination:="Sheet4!R3C1", TableName:="PivotTable1", _
    DefaultVersion:=xlPivotTableVersion14

Any suggestions or solutions would be much appreciated. Thank you very much!

1
maybe pivotTable1 name is already in use.Poof
Do all the columns have a header, in row 1 column 1 to column 15?Jasper
could you also provide us a screenshot of the list which is used as datsource?psychicebola
Hi, don't know if this is a typo on the post, but the Source Data is not properly spelled. You are missing a !... should read "Sheet3!R1C1:R671950C15" for a proper range.Dan

1 Answers

0
votes

Because of the error mesage it could be that the database you are trying to read and bring into a Pivot Table has one or more columns without a name/label. Make sure all columns you are using have some data on the first row.