+ Reply to Thread
Results 1 to 5 of 5

Replaying a pivot table in a macro

Hybrid View

  1. #1
    Registered User
    Join Date
    02-08-2007
    Posts
    7

    Replaying a pivot table in a macro

    Hello

    I recorded a simple pivot table using a macro however when i try to repay it i get the error:

    'Unable to get the pivot tables probperty of the worksheet class'

    The debugger points at this line of code:

    HTML Code: 

    I renamed the pivot table so its not clashing with an already existing table and other then that i dont know or cant find out what to do. Any advice would be greatly appreciated.

    Thanks a million

  2. #2
    Forum Contributor
    Join Date
    09-04-2006
    Location
    Yorkshire, England
    Posts
    267
    can you post a bit more of the surrounding code?
    Or your workbook(in a compressed folder)?
    JR
    Versions
    Mac OS X 'Leopard'
    Mac MS Office Excel 2004
    Windows XP
    MS Excel 2002
    MS Excel 2003

  3. #3
    Registered User
    Join Date
    02-08-2007
    Posts
    7
    ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
            "'DAAREP Month'!R1C5:R329C5").CreatePivotTable TableDestination:= _
            "'[VIP Report.xls]Interim'!R1C1", TableName:="PivotTable6", DefaultVersion _
            :=xlPivotTableVersion10
        ActiveWorkbook.ShowPivotTableFieldList = True
            
            
             With ActiveSheet.PivotTables("PivotTable6").PivotFields("Category")
            .Orientation = xlRowField
            .Position = 1
            Range("A1").Select
        End With
        ActiveSheet.PivotTables("PivotTable6").AddDataField ActiveSheet.PivotTables( _
            "PivotTable6").PivotFields("Category"), "Count of Category", xlCount
        Sheets("Interim").Select

    Thank you!!!!

  4. #4
    Forum Contributor
    Join Date
    09-04-2006
    Location
    Yorkshire, England
    Posts
    267
    Just a two quick questions:
    1.You renamed your pivot table from 'PivotTable6' or to 'PivotTable6'.
    2. In the following

    With ActiveSheet.PivotTables("PivotTable6").PivotFields("Category")
            .Orientation = xlRowField
            .Position = 1
    what is "Catagory" (in the pivot fields part) is it a field you created like row or column?

  5. #5
    Registered User
    Join Date
    02-08-2007
    Posts
    7
    Hi JR

    I changed it to PivotTable6 and category is the name of the column that i want to construct the pivot table from.

    Thanks again

+ Reply to Thread

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