Results 1 to 10 of 10

Hide and show pivotfields with vba

Threaded View

  1. #1
    Forum Contributor
    Join Date
    05-24-2014
    MS-Off Ver
    Microsoft Office 2013
    Posts
    113

    Hide and show pivotfields with vba

    I have a pivot chart that I would like to make more interactive and allow the user to select which data they would like to see. I didn't know the code to do this so I recorded a macro of when I changed what was seen. I took one off, then brought it back and changed it so it would average the data. I then tried to run through the macro and it kept giving me an error. I have posted my code below. Once I can get the basics done on this I will go ahead and use if formulas with my checkboxes to make it work how I would like. Any help would be great.

    Sub Macro15()
    '
    ' Macro15 Macro
    
        ActiveSheet.ChartObjects("Chart 1").Activate
        ActiveWorkbook.ShowPivotTableFieldList = True
        ActiveChart.PivotLayout.PivotTable.PivotFields("Documented in Excel"). _
            Orientation = xlHidden
        ActiveWorkbook.ShowPivotTableFieldList = False
        
        ActiveSheet.ChartObjects("Chart 1").Activate
        ActiveWorkbook.ShowPivotTableFieldList = True
        ActiveChart.PivotLayout.PivotTable.AddDataField ActiveChart.PivotLayout. _
            PivotTable.PivotFields("Documented in Excel"), "Sum of Documented in Excel", _
            xlSum
        With ActiveChart.PivotLayout.PivotTable.PivotFields( _
            "Sum of Documented in Excel")
            .Caption = "Average of Documented in Excel"
            .Function = xlAverage
        End With
        ActiveWorkbook.ShowPivotTableFieldList = False
    End Sub
    Last edited by manofcheese; 05-29-2014 at 03:18 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Show/Hide Shape VBA
    By maacmaac in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-06-2013, 09:03 AM
  2. VBA hide row based on pull down with button to toggle show/hide
    By myronr in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-12-2012, 06:07 PM
  3. Pivotfields & Pivotitems VBA
    By pickledmuffin in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-08-2008, 06:12 PM
  4. [SOLVED] PivotFields problem
    By Tim in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-17-2005, 01:35 PM
  5. [SOLVED] Hide and show Rows
    By Duane in forum Excel General
    Replies: 2
    Last Post: 04-19-2005, 06:06 PM

Tags for this Thread

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