Wednesday, 29 August 2012

VB.NET - EXCEL - How to fix error "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."

VB.NET - EXCEL - How to fix error "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."   

Replace
         ptField = ptTable.PivotFields("FieldName")
            With ptField
                .Orientation = Excel.XlPivotFieldOrientation.xlColumnField
                .Name = ""
            End With
With

         ptField = ptTable.PivotFields("FieldName")
            With ptField
                .Orientation = Excel.XlPivotFieldOrientation.xlColumnField
                .Name = " "
            End With

.Name cannot be the same as ("FieldName") and cannot be empty

No comments:

Post a Comment