+ Reply to Thread
Results 1 to 2 of 2

run time error 1004 when using macro to change pivot Table fields.

Hybrid View

  1. #1
    Registered User
    Join Date
    02-26-2011
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    10

    run time error 1004 when using macro to change pivot Table fields.

    Hi All,

    I have arranged data using a pivot table and want to display the data
    using a pivot chart, which I have been able to do.

    I have recorded a basic macro which should (in theroey) change the Value field in the pivot table. However when i run the macro I get the following error message:
    Run-Time error 1004
    Unable to get the PivotFields property of the Pivoit Table Class.
    The code is as follows:
    Sub Water()
    '
    ' Water Macro
    
        Sheets("Sheet1").Select
        Range("I2").Select
        ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of Result"). _
        ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
            "PivotTable1").PivotFields("Water"), "Count of Water", xlCount
        ActiveWorkbook.ShowPivotTableFieldList = False
        Sheets("Flux Levels").Select
    End Sub
    When I run the deubg option the error seems to be occuring on the 3rd and 4th lines of the code.

    Any suggestions?

    Thanks!

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,282

    Re: run time error 1004 when using macro to change pivot Table fields.

    The third line makes no sense - what is it supposed to do?
    Remember what the dormouse said
    Feed your head

+ 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