LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default create pivot table in VBA

I am trying to create a very simple pivot table from a datafile in a macro. I
can manually do all the steps but when I record the steps I get the error
Add Fields method of PivotTable Class failed. Can someone point out this
newbie's error?
thanks
Sub test1()
'
' test1 Macro
' Macro recorded 3/22/2007 by LUPF
'

'
Workbooks.OpenText Filename:="M:\Reporting\TES_CODER.txt", Origin:=437, _
StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False,
Comma:=False _
, Space:=False, Other:=True, OtherChar:="~",
FieldInfo:=Array(Array(1, 1 _
), Array(2, 1), Array(3, 1), Array(4, 3), Array(5, 1), Array(6, 2),
Array(7, 1), Array(8, 1), _
Array(9, 1)), TrailingMinusNumbers:=True
Columns("G:G").Select
Selection.NumberFormat = "0.00"
Range("A1:I1").Select
Selection.Font.Bold = True
Cells.Select
Cells.EntireColumn.AutoFit



ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
"TES_CODER!C1:C2").CreatePivotTable TableDestination:="",
TableName:= _
"PivotTable1", DefaultVersion:=xlPivotTableVersion10
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select
ActiveSheet.PivotTables("PivotTable1").AddFields RowFields:="Modified
User" '******* ERROR HERE ********

ActiveSheet.PivotTables("PivotTable1").PivotFields ("Transaction").Orientation
_
= xlDataField
ActiveWorkbook.ShowPivotTableFieldList = False
Application.CommandBars("PivotTable").Visible = False
End Sub

rdavid2
 
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 to create pivot table from existing pivot table in excel 2007 Udayraj Dhulekar Excel Discussion (Misc queries) 2 July 8th 13 08:22 PM
can I create pivot table from two other pivot tables? pjk@boro Excel Discussion (Misc queries) 5 June 13th 09 12:13 PM
How do I create multiple pivot charts from one pivot table? Rudy Charts and Charting in Excel 1 March 17th 06 10:01 PM
pivot table: create worksheetsheet using pivot table Pivot Tables and New Worksheets Excel Discussion (Misc queries) 1 June 1st 05 10:01 PM
How do I create a pivot table if the pivot table icon or menu ite. Lynn@WS Charts and Charting in Excel 1 December 16th 04 02:36 AM


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

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

About Us

"It's about Microsoft Excel"