Results 1 to 7 of 7

Object Required Error

Threaded View

  1. #1
    Registered User
    Join Date
    12-23-2011
    Location
    pomona, ca
    MS-Off Ver
    Excel 2010
    Posts
    36

    Object Required Error

    Hi All,

    I have run into an error in creating a pivot table. The error says object required, but I believe that I already have an object there. I'm sure this will be easy for the wiz' out there! The error occurs after the pivot table is created and where I start the "with PT." Thanks!

    samplewb.xlsm

    Sub Pivot()
    
    Dim PTCache As PivotCache
    Dim PT As PivotTable
    
    'Create Cache
    Set PTCache = ActiveWorkbook.PivotCaches.Create( _
        SourceType:=xlDatabase, _
        SourceData:=Sheets("Breakdown").Range("a1").CurrentRegion)
        
    'Add a New WS to the WB
    Worksheets.Add.Name = "Pivot"
    
    'Create Pivot Table
    Set PT = ActiveSheet.PivotTables.Add( _
        PivotCache:=PTCache, _
        tabledestination:=Range("a1"))
        
    'Specify the fields
    With PT
        .PivotFields("Notification Reference Date").Orientation.xlColumnField
        .PivotFields("Equipment Name").Orientation.xlRowField
        .PivotFields("District Text").Orientation.xlRowField
        .PivotFields("Equipment Name").Orientation.xlDataField
        'no field captions
        .DisplayFieldCaptions = False
    End With
    
    Range("B2").Select
        Selection.Group Start:=True, End:=True, Periods:=Array(False, False, False, _
            False, True, False, False)
        
        
    End Sub
    Last edited by tlinton; 06-12-2012 at 10:44 AM.

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