Loading
Ozgrid Excel Help & Best Practices Forums

Excel Video Tutorials / Excel Dashboards Reports



Results 1 to 3 of 3

Thread: Unable to Get The PivotFields Property of PivotTable Class

  1. #1
    Join Date
    26th May 2005
    Posts
    13

    Unable to Get The PivotFields Property of PivotTable Class

    I recorded the following code using the 'Record Macro' option. The macro does not work properly when I run it and I receive the following error message:
    Runtime Error: '1004' Unable to get the PivotFields property of PivotTable class

    The macro only pulls in the PivotFiled- 'Result' into the Pivot Tables dialog box, it gives me an error when it tries to pull the 'Part#' and 'Date' fields.

    Thanks in advance

    VB:
    Cells.Select 
    Selection.Copy 
    Sheets.Add 
    ActiveSheet.Paste 
    Sheets("Sheet1").Select 
    Sheets("Sheet1").Name = "Reporter" 
    Range("D1").Select 
    Application.CutCopyMode = False 
    ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _ 
    "Reporter!C1:C3").CreatePivotTable TableDestination:=Range("D1"), TableName _ 
    :="PivotTable1" 
    With ActiveSheet.PivotTables("PivotTable1") 
        .NullString = "0" 
        .RowGrand = False 
        .SmallGrid = False 
    End With 
    With ActiveSheet.PivotTables("PivotTable1").PivotFields("PART#") 
        .Orientation = xlRowField 
        .Position = 1 
    End With 
    With ActiveSheet.PivotTables("PivotTable1").PivotFields("RESULT") 
        .Orientation = xlColumnField 
        .Position = 1 
    End With 
    With ActiveSheet.PivotTables("PivotTable1").PivotFields("DATE") 
        .Orientation = xlDataField 
        .Position = 1 
    End With 
    
    
    Last edited by Dave Hawley; November 29th, 2006 at 10:40.

    Excel Video Tutorials / Excel Dashboards Reports


  2. #2
    Join Date
    14th January 2005
    Location
    Cyprus
    Posts
    2,252

    Re: Runtime Error1004: Pivot Tables

    It looks like your source data is just one column
    VB:
    SourceData:= "Reporter!C1:C3" 
    
    
    Do you have the result in column C ? Try extending the range .

    HTH
    Carl

    Excel Video Tutorials / Excel Dashboards Reports


  3. #3
    Join Date
    26th May 2005
    Posts
    13

    Re: Runtime Error1004: Pivot Tables

    I can't believe I missed that... I manually changed the range to refer to Columns A to C in line 2 below--->

    VB:
     
    ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _ 
    "Sheet13!A:C").CreatePivotTable TableDestination:="", TableName:= _ 
    "PivotTable2" 
    
    
    Funny thing is, when I record the Macro; even though I select the columns A:C, it still records it as C1:C3.

    I've learned my lesson. Thank you v. much.
    Last edited by Dave Hawley; November 29th, 2006 at 10:40.

    Excel Video Tutorials / Excel Dashboards Reports


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Possible Answers

  1. Replies: 3
    Last Post: October 15th, 2011, 03:38
  2. Unable To Set Name Property of Series Class
    By cynosureofitall in forum EXCEL HELP
    Replies: 4
    Last Post: November 14th, 2006, 18:05
  3. Replies: 4
    Last Post: September 19th, 2006, 05:05
  4. Unable to get the add Property of the add in Class
    By Jo Lucas in forum EXCEL HELP
    Replies: 5
    Last Post: September 9th, 2006, 11:00
  5. Replies: 1
    Last Post: August 24th, 2006, 12:54

Bookmarks

Posting Permissions

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