Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Creating Pivot Table with VBA

Hello,

i have the following problem:

i try to create a pivot table with vba but it doesn't work.
i have some data (named columns A to N)

ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
"zac01!C1:C14").CreatePivotTable TableDestination:="", TableName:= _
"PivotTable2"
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
"zac01!C1:C14").CreatePivotTable TableDestination:="", TableName:= _
"PivotTable2"

i try to make the pivot

ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
With ActiveSheet.PivotTables("PivotTable2")
.ColumnGrand = False
.RowGrand = False
.SmallGrid = False
End With

when i add my fields, i receive an error: method addfields failed

ActiveSheet.PivotTables("PivotTable2").AddFields RowFields:=Array( _
"Sold-to Name", "Data"), ColumnFields:="Date",
PageFields:="Material"

= at this moment, i can see a list of the fields (with the wizard, but
there is only one field in the list) ???????
how can this be ? I selected col A to N ?


than you for your help


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Creating Pivot Table with VBA

In your code you specify:
SourceData:= _
"zac01!C1:C14").

try changing it to

SourceData:= _
"zac01!A1:N14").

--
Regards,
Tom Ogilvy


"Eric Lecocq" wrote in message
...
Hello,

i have the following problem:

i try to create a pivot table with vba but it doesn't work.
i have some data (named columns A to N)

ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
"zac01!C1:C14").CreatePivotTable TableDestination:="", TableName:=

_
"PivotTable2"
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
"zac01!C1:C14").CreatePivotTable TableDestination:="", TableName:=

_
"PivotTable2"

i try to make the pivot

ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
With ActiveSheet.PivotTables("PivotTable2")
.ColumnGrand = False
.RowGrand = False
.SmallGrid = False
End With

when i add my fields, i receive an error: method addfields failed

ActiveSheet.PivotTables("PivotTable2").AddFields RowFields:=Array( _
"Sold-to Name", "Data"), ColumnFields:="Date",
PageFields:="Material"

= at this moment, i can see a list of the fields (with the wizard, but
there is only one field in the list) ???????
how can this be ? I selected col A to N ?


than you for your help




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Creating Pivot Table with VBA

Thank you very much !!!!


"Tom Ogilvy" wrote in message
...
In your code you specify:
SourceData:= _
"zac01!C1:C14").

try changing it to

SourceData:= _
"zac01!A1:N14").

--
Regards,
Tom Ogilvy


"Eric Lecocq" wrote in message
...
Hello,

i have the following problem:

i try to create a pivot table with vba but it doesn't work.
i have some data (named columns A to N)

ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:=

_
"zac01!C1:C14").CreatePivotTable TableDestination:="",

TableName:=
_
"PivotTable2"
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:=

_
"zac01!C1:C14").CreatePivotTable TableDestination:="",

TableName:=
_
"PivotTable2"

i try to make the pivot

ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3,

1)
With ActiveSheet.PivotTables("PivotTable2")
.ColumnGrand = False
.RowGrand = False
.SmallGrid = False
End With

when i add my fields, i receive an error: method addfields failed

ActiveSheet.PivotTables("PivotTable2").AddFields RowFields:=Array( _
"Sold-to Name", "Data"), ColumnFields:="Date",
PageFields:="Material"

= at this moment, i can see a list of the fields (with the wizard, but
there is only one field in the list) ???????
how can this be ? I selected col A to N ?


than you for your help






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I detail Pivot Table data without creating a table (Excel2007) Skeletiko[_2_] Excel Discussion (Misc queries) 1 May 5th 10 08:22 AM
How can I detail Pivot Table data without creating a table (Excel2007) Skeletiko Excel Discussion (Misc queries) 0 May 5th 10 12:21 AM
creating a report from a table, pivot table not suitable UKMAN Excel Worksheet Functions 1 April 16th 10 08:35 AM
creating a pivot table from 4 pivot tables phyllis W Excel Worksheet Functions 0 October 12th 08 09:52 PM
Creating a Pivot Table lkw441 Charts and Charting in Excel 1 June 7th 05 04:06 AM


All times are GMT +1. The time now is 07:42 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"