pivot tables name

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Pivot Tables Name

Pivot Tables Name

resolvedResolved · Low Priority · Version 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:

Customize the toolbar in Excel 2010

You can create your own toolbar which contains your favourite or most used tools. This will make using Excel much more efficient. To do this, you need to click on View, then select Customize Quick access Toolbars and then select Customize. A list of tools will then appear on the screen of which you can add or remove them as you please.

View all Excel hints and tips


Server loaded in 0.07 secs.