简体   繁体   中英

Excel VBA pivot table issue

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM