tonysarris
New Member
- Joined
- Feb 7, 2014
- Messages
- 1
Hello,
I need to create some quality reports for my work and run into this "strange problem".
I create some pivot tables from raw data and then create the charts visualizing each pivot table.
Trying to represent with green or red, if the specific platforms we build meet the first pass yield customer demands, i want to change the data label colors of the charts.
Everything works, I can say perfect except the fact that after the code save and close the report and publish it in PDF (so far with no issue), when i reopen the report in the excel format all labels adopt not only the value as was before the save but include "series name","category name" which i do not want.
I copy the part of code that changes the color depends the target value.
It is my first time writing code so please if there is any way improve this let me know.
Thanks in advance
I need to create some quality reports for my work and run into this "strange problem".
I create some pivot tables from raw data and then create the charts visualizing each pivot table.
Trying to represent with green or red, if the specific platforms we build meet the first pass yield customer demands, i want to change the data label colors of the charts.
Everything works, I can say perfect except the fact that after the code save and close the report and publish it in PDF (so far with no issue), when i reopen the report in the excel format all labels adopt not only the value as was before the save but include "series name","category name" which i do not want.
I copy the part of code that changes the color depends the target value.
It is my first time writing code so please if there is any way improve this let me know.
Thanks in advance
Code:
For HowManyFormFactorLoop = 1 To HowManyFormFactor 'how many actually pivot tables and charts exist. form factor is a group of platforms
'Mark the red and green points in the chart
ActiveSheet.ChartObjects(HowManyFormFactorLoop).Activate 'I activate the chart
Category = ActiveChart.SeriesCollection(1).XValues 'I need the category so i can track the target from a target table
For CHSeriesCount = 1 To ActiveChart.SeriesCollection.Count 'looping through the series
CategoryPoints = ActiveChart.SeriesCollection(CHSeriesCount).Values 'Grab all the data labels values to check if they are above or below the target
ActiveChart.SeriesCollection(CHSeriesCount).DataLabels.NumberFormat = "0%"
For i = 1 To UBound(CategoryPoints) 'looping through the data labels for each series
Target = Application.WorksheetFunction.VLookup(Category(i), WB.Sheets("PlatformsTargets").Range("A1").CurrentRegion, 2, False)
If CategoryPoints(i) >= Target Then
ActiveChart.SeriesCollection(CHSeriesCount).Points(i).DataLabel.Format.TextFrame2.TextRange.Font.Fill.ForeColor.RGB = RGB(0, 255, 0)
Else
ActiveChart.SeriesCollection(CHSeriesCount).Points(i).DataLabel.Format.TextFrame2.TextRange.Font.Fill.ForeColor.RGB = RGB(255, 0, 0)
End If
Next i
Next CHSeriesCount
Next HowManyFormFactorLoop
Last edited by a moderator: