Solved

Possible to highlight a specific vertical axis gridline?

Posted on 2014-03-17
7
194 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

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

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

810 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