Solved

Possible to highlight a specific vertical axis gridline?

Posted on 2014-03-17
7
190 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 48

Expert Comment

by:Rgonzo1971
Comment Utility
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
Comment Utility
Great - can you please tell me the object reference code to set that formula?
0
 
LVL 48

Accepted Solution

by:
Rgonzo1971 earned 500 total points
Comment Utility
Hi,

 to set the formula.

pls use

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

Open in new window

Regards
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:mlagrange
Comment Utility
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 48

Expert Comment

by:Rgonzo1971
Comment Utility
No it does the change directly as far as I know
0
 

Author Comment

by:mlagrange
Comment Utility
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
Comment Utility
Thanks!
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

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…
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

771 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

10 Experts available now in Live!

Get 1:1 Help Now