Solved

Possible to highlight a specific vertical axis gridline?

Posted on 2014-03-17
7
193 Views
Last Modified: 2014-03-18
Hello - I am developing a pivot chart on employee rewards data for a company, and they want to see if the divisions are meeting a 5% rewards goal for each quarter, and in line to make a 20% goal for the year.  

I’ve stumbled upon the right object references to set the chart title when the user changes the “Qtr” chart filter, but what I really need to do is highlight (red, bold) the 5% vertical grid line when the user selects Qtr 1, 2, 3 or 4, and highlight the 20% gridline when they select the “All” value for year-to-date.

(screen shots posted, I am familiar with VBA, this is Excel 2010)

Is this possible?

Thanks
GRR-Chart-Q1.png
GRR-Chart-YTD.png
0
Comment
Question by:mlagrange
  • 4
  • 3
7 Comments
 
LVL 49

Expert Comment

by:Rgonzo1971
ID: 39934011
Hi,
You could add a field wit =0.05 in the formula and chane the chart type of this serie

then when changing the filter of the pivot change the formula to =0.2

EERegards
0
 

Author Comment

by:mlagrange
ID: 39934951
Great - can you please tell me the object reference code to set that formula?
0
 
LVL 49

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 39935032
Hi,

 to set the formula.

pls use

 ActiveSheet.PivotTables("PivotTable1").CalculatedFields("Field1"). _
        StandardFormula = "=0.2"

Open in new window

Regards
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:mlagrange
ID: 39935048
Does that need to be followed by some kind of Refresh or something? when I step through that in debug mode, it executes that statement, and then loops back up to the "Private Sub" line (the top of the procedure)
0
 
LVL 49

Expert Comment

by:Rgonzo1971
ID: 39935088
No it does the change directly as far as I know
0
 

Author Comment

by:mlagrange
ID: 39937029
ok, figured it out - setting this formula in VBA actually fires the Worksheet_PivotTableUpdate() event itself! That's why it kept jumping up to the top of the proc after .StandardFormula line

Then it was talking 2 updates of the quarter filter (selecting the same value, twice) before it actually refreshed the chart. So I added a .PivotCache.Refresh

So here is the code:

    Application.EnableEvents = False
   
    Select Case ActiveSheet.PivotTables("pvtL1").PivotFields("AwardQtr").CurrentPage
        Case "Q1", "Q2", "Q3", "Q4"
            ActiveSheet.PivotTables("pvtL1").CalculatedFields("GoalLine").StandardFormula = "=0.05"
        Case Else
            ActiveSheet.PivotTables("pvtL1").CalculatedFields("GoalLine").StandardFormula = "=0.20"
    End Select
   
    ActiveSheet.PivotTables("pvtL1").PivotCache.Refresh
       
    Application.EnableEvents = True
   
 Thanks for your help.

(PLEASE take a look at the question I posted this morning:
http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Excel/Q_28390967.html
0
 

Author Closing Comment

by:mlagrange
ID: 39937037
Thanks!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Excel 2013 Power Query 1 46
How to Calculate Stainless Steel U-Bolt Dimension 15 65
ActiveX Listbox Multi Select in Excel 2010 8 16
increment numbers by 10 11 26
INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

943 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now