ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Error when runing macro to create pivot table (https://www.excelbanter.com/excel-programming/305853-error-when-runing-macro-create-pivot-table.html)

Bruno[_3_]

Error when runing macro to create pivot table
 
Hi,
I created a macro (recorded macro)to make a pivot Table.
The generated code is the following:
(...)
Columns("A:H").Select
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase,
SourceData:= _
"relat!C1:C8").CreatePivotTable
TableDestination:="", TableName:= _
"TD Vendas"
ActiveSheet.Name = "TPVsIva"
ActiveSheet.PivotTableWizard
TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select

ActiveSheet.PivotTables("TD Vendas").SmallGrid = False

ActiveSheet.PivotTables("TD Vendas").AddFields
RowFields:=Array( _
"Estrutura", "Dados"), PageFields:="Loja"
(...)
When I run the macro appears an error in the last line,
where I'm adding fields.
The error is : "Run Time Error '1004'" with the
message "It was not possible to execute the
Addfields method of the
PivotTables collection"

Can you help me?

Thanks
Bruno
..




All times are GMT +1. The time now is 05:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com