Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

pivot tables name

ResolvedVersion 2003

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(

 

Training courses

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.

Excel tip:

Auto-insert the current time

In Microsoft Excel, to enter the current time into a cell, hold CTRL+SHIFT and press SEMICOLON.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.1 secs.