Results 1 to 5 of 5

Error 1004 on Macro to refresh pivot tables

Threaded View

  1. #1
    Forum Contributor
    Join Date
    12-02-2009
    Location
    Birmingham, UK
    MS-Off Ver
    2007
    Posts
    185

    Error 1004 on Macro to refresh pivot tables

    Hello,

    I have occurred a problem with my macros.

    I have a document that contains 5 worksheets.

    Worksheet1 is a data, which is used for three different pivot tables each located in different worksheet.

    Worksheet 1 – Daily movements
    Worksheet 2 – Balance by Part (StockByPart - Pivot table)
    Worksheet 3 – Balance by SubCons (StockBySubCon – pivot table)
    Worksheet 4 – Outstanding and Arrears (Balance – pivot table)
    Worksheet 5 – Sheet3

    This is my latest amendment to the first macro:

    Sub RefreshParts()
    '
    Sheets("Balance by Part").Activate
    ActiveSheet.PivotTables("StockByPart").RefreshTable
    '
    End Sub
    
    Sub RefreshSubCon()
    '
    Sheets("Balance by SubCons").Activate
    ActiveSheet.PivotTables("StockBySubCon").RefreshTable
    '
    End Sub
    
    Sub RefreshOutstanding()
    '
    Sheets("Outstanding and Arrears").Activate
    ActiveSheet.PivotTables("Balance").RefreshTable
    '
    End Sub
    
    Sub CallAll()
    '
    Call RefreshParts
    Call RefreshSubCon
    Call RefreshOutstanding
    Sheets("Balance by Part").Activate
    ActiveSheet.Range("A1").Select
    '
    End Sub
    Previous to that I had:
    Sub RefreshParts()
    '
    Sheets("Balance by Part").PivotTables("StockByPart").RefreshTable
    '
    End Sub
    
    Sub RefreshSubCon()
    '
    Sheets("Balance by SubCons").PivotTables("StockBySubCon").RefreshTable
    '
    End Sub
    
    Sub RefreshOutstanding()
    '
    Sheets("Outstanding and Arrears").PivotTables("Balance").RefreshTable
    '
    End Sub
    
    Sub CallAll()
    '
    Call RefreshParts
    Call RefreshSubCon
    Call RefreshOutstanding
    Sheets("Balance by Part").Activate
    ActiveSheet.Range("A1").Select
    '
    End Sub
    But my first macro was:


    Sub RefreshTables()
    ‘
    Sheets(“BalanceByPart”).PivotTables(“StockByPart”).RefreshTable
    Sheets(“Balance by SubCons”).PivotTables(“StockBySubCon”).RefreshTable
    Sheets(“Outstanding and Arrears”).PivotTables(“Balance”).RefreshTable
    ‘
    End
    I do not understand why from the very beginning I cannot overcome the “Run-time error 1004. Unable to get the Pivot Tables property of the Worksheet class”

    If need be I will upload the workbook to have a look unless someone ca spot the mistake I have made in the first place.

    Thanks for reading this.

    Simon
    Last edited by Ramzes; 10-12-2010 at 06:54 AM.
    ...and this is when I walk in, dressed fully in white...

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