Results 1 to 1 of 1

Pivot table giving 'runtime error 1004'

Threaded View

  1. #1
    Registered User
    Join Date
    04-23-2007
    Location
    Chicago Suburbs
    Posts
    32

    Pivot table giving 'runtime error 1004'

    I am running a macro that creates a pivot table and it seems to work ok if I can choose the cells to run the pivot table on. It is not possible to set up a default as the report changes in rows but not in columns. When I record using all cells, I get an error of 'runtime error 1004'
    Unable to get the pivot table property of the pivot table class.
    Seems to me that it almost needs to pause to let the pivot function catch up with the rest of macro.
    Here is the code inside the debugger
    Sub pivot6()
    '
    ' pivot6 Macro
    ' Macro recorded 12/21/2007 by Christopher E Wantuch
    '
    
    '
        Cells.Select
        ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
            "Sheet1!C1:C13").CreatePivotTable TableDestination:="", TableName:= _
            "PivotTable1", DefaultVersion:=xlPivotTableVersion10
        ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
        ActiveSheet.Cells(3, 1).Select
        With ActiveSheet.PivotTables("PivotTable1").PivotFields("Posting Date")
            .Orientation = xlRowField
            .Position = 1
        End With
        ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
            "PivotTable1").PivotFields("Total Direct Hours"), "Count of Total Direct Hours" _
            , xlCount
        Range("B12").Select
        ActiveSheet.PivotTables("PivotTable1").PivotFields( _
            "Count of Total Direct Hours").Function = xlSum
    End Sub
    Any help would be greatly appreciated.
    Last edited by wantucce; 12-21-2007 at 06:47 PM.

Thread Information

Users Browsing this Thread

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

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1