Rebecca has attended:
Excel Advanced course
Pivot Tables Name
Hi,
I am writing a code to create a pivot table. Part of the code is:
ActiveSheet.PivotTableWizard SourceType:=xlDatabase, _
SourceData:=DataRange, tabledestination:=Destination, tablename:="SupplierInfo"
Whenever I run the Macro and error occurs saying the Pivot Table field name is not valid and data must be organised as a list with labled columns. If Iam changing the name of the Pivottable field, I must type in a new name for the field.
What am I doing wrong?
Many thanks
Becky
RE: Pivot Tables Name
Hi Becky
Without seeing how your data is set up from what you said above it seems that your DataRange is not picking up the full table including the column labels which are taken by the system and converted to the pivottable field names.
The example code below sets the DataRange as a table whose column labels start in cell A9 and the destination on another sheet.
You will notice you need to pick up in full the table that contains the data to be pivoted so that when you populate the pivot table the computer knows which fields to use.
Sub MyPivot()
Dim DataRange As Range
Dim Destination As Range
Dim PvtTable As PivotTable
Sheets(