+ Reply to Thread
Results 1 to 6 of 6

PivotTable slicers and filtering removes secondary axis for chart

  1. #1
    Registered User
    Join Date
    03-22-2019
    Location
    Los Angeles
    MS-Off Ver
    2013
    Posts
    34

    PivotTable slicers and filtering removes secondary axis for chart

    Hello,

    I have a large worksheet that I am working on, but everytime I filter and or use the slicers the secondary axis I setup goes away.
    Is there a way to circumvent this? Attached is a sample workbook with the correctly formatted chart.

    I found the following forum post from 2013. Where is the pivotchange event, and how do I add code to the pivotchange event to reset the chart formatting as stated in the post below?

    https://www.excelforum.com/excel-cha...-my-graph.html

    char2ndtAxis.png
    Attached Files Attached Files

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: PivotTable slicers and filtering removes secondary axis for chart

    The pivotchange event would be in the sheet object that the pivot table is on.

    As you have your pivotchart on a chart sheet you can use the change event of the chart.
    Right click chart tab and pick View Code. Paste the following

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    03-22-2019
    Location
    Los Angeles
    MS-Off Ver
    2013
    Posts
    34

    Re: PivotTable slicers and filtering removes secondary axis for chart

    Quote Originally Posted by Andy Pope View Post
    The pivotchange event would be in the sheet object that the pivot table is on.

    As you have your pivotchart on a chart sheet you can use the change event of the chart.
    Right click chart tab and pick View Code. Paste the following

    Please Login or Register  to view this content.
    Wow thank you so much for this! I understand what's the code is doing based on my research on the InStr function. I also want to add a primary and secondary label to the vertical access, but I am getting a runtime error 424, object required (red line). Building on your code I've added the following:
    It's my understanding that the code within the With Loop all belong to the same object, ActiveChart, so I don't know why I get the error.
    Please Login or Register  to view this content.

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: PivotTable slicers and filtering removes secondary axis for chart

    Please don't quote whole posts -- it's just clutter.*If you are responding to a post out of sequence, limit quoted content to a few relevant lines that makes clear to whom and what you are responding

    try this revision
    Please Login or Register  to view this content.
    I have moved the code out of the loop so it only gets executed once, rather than for each series.

  5. #5
    Registered User
    Join Date
    03-22-2019
    Location
    Los Angeles
    MS-Off Ver
    2013
    Posts
    34

    Re: PivotTable slicers and filtering removes secondary axis for chart

    Quote Originally Posted by Andy Pope View Post
    Please don't quote whole posts -- it's just clutter.*If you are responding to a post out of sequence, limit quoted content to a few relevant lines that makes clear to whom and what you are responding
    Will do. Thank you for the revision. It works perfectly.

  6. #6
    Registered User
    Join Date
    08-19-2021
    Location
    ohio,US
    MS-Off Ver
    2016
    Posts
    1

    Re: PivotTable slicers and filtering removes secondary axis for chart

    I am trying to use the above example to solve this issue, however I am finding if my slicer choice does not have any data for the secondary axis, then I remove the filter - the secondary axis disappears. The above code did not resolve this issue. I am using Power Query to link to over 600,000 lines of data. I am a self taught novice - so please if you are so kind to respond I may not fully understand acronyms or "excel speak"

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Primary Axis & secondary Axis have high gap to show in chart
    By leakhna in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 07-05-2018, 02:19 AM
  2. [SOLVED] How to keep scale of chart with secondary axis the same, after deleting the axis'
    By luv2glyd in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 02-14-2017, 02:28 PM
  3. Secondary Axis disappears when using slicers
    By TsBanfill in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 08-20-2015, 08:28 PM
  4. Replies: 1
    Last Post: 05-03-2006, 09:20 PM
  5. Replies: 2
    Last Post: 08-12-2005, 08:05 AM
  6. Replies: 0
    Last Post: 07-13-2005, 05:05 PM
  7. [SOLVED] How do I set permanent secondary axis in PivotTable chart?
    By Microlong in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 01-08-2005, 12:06 AM

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