Results 1 to 2 of 2

Thread: [RESOLVED] Pivot Table problem

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Location
    Montreal, Canada
    Posts
    152

    Resolved [RESOLVED] Pivot Table problem

    Hi,
    I recorded a macro that create a pivot table that gives me the following:

    VB Code:
    1. Sub Macro2()
    2. '
    3.     ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
    4.         "BHD20060423!C1:C20").CreatePivotTable TableDestination:="", TableName:= _
    5.         "PivotTable2", DefaultVersion:=xlPivotTableVersion10
    6.     ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
    7.     ActiveSheet.Cells(3, 1).Select
    8.     ActiveSheet.PivotTables("PivotTable2").AddFields RowFields:=Array("Class", _
    9.         "SEA/BAS", "Data"), ColumnFields:="FY&P"
    10.     With ActiveSheet.PivotTables("PivotTable2").PivotFields("OnOrder (Current)")
    11.         .Orientation = xlDataField
    12.         .Caption = "Sum of OnOrder (Current)"
    13.         .Position = 1
    14.         .Function = xlSum
    15.     End With
    16.     With ActiveSheet.PivotTables("PivotTable2").PivotFields("OnOrder (Units)")
    17.         .Orientation = xlDataField
    18.         .Caption = "Sum of OnOrder (Units)"
    19.         .Function = xlSum
    20.     End With
    21. End Sub


    It worked the time I recorded it, but not anymore.
    I'm having an AddField method of PivotTable class failed error at the line

    VB Code:
    1. ActiveSheet.PivotTables("PivotTable2").AddFields RowFields:=Array("Class", _
    2.         "SEA/BAS", "Data"), ColumnFields:="FY&P"

    I don't know what the field "Data" is doing there, I didn't add it in the Wizard.

    If there is a better way here is what I want to do.

    Each week a workbook is created with ONE sheet in it, the sheet name change each week.
    Data(Header) is starting at A1 and finish a T??? but always column T
    In the Wizard I enter in the layout section for Row the field Class and the field SEA/BAS. For the Column I entering the field FY&P
    In the data section I'm entering the Sum of OnOrder (Current) and Sum of OnOrder (Units)

    The Pivot table has to be on a new sheet.
    Really Need help here

    Thanks

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Location
    Montreal, Canada
    Posts
    152

    Re: Pivot Table problem

    solved********

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width