anappleuser
New Member
- Joined
- Aug 5, 2014
- Messages
- 9
Hi I am developing a macro which Removes less than 5.00% data from charts. (Just removes from Charts, Not from inside datasheet).
I got problem in Cluster Bar chart type in which I want to Apply two condition. If Chart type is 57 (XlBarCluster) and also Has Axis then Do not show data labels on chart Else Show data labels on Chart. Below is my code but it is giving error on Highlighted Part. Please Help.
--------------------------------------
I got problem in Cluster Bar chart type in which I want to Apply two condition. If Chart type is 57 (XlBarCluster) and also Has Axis then Do not show data labels on chart Else Show data labels on Chart. Below is my code but it is giving error on Highlighted Part. Please Help.
Code:
Sub RemoveSmallValuesFromExecutiveReportCharts()
For Each Slide In ActivePresentation.Slides
For Each Shape In Slide.Shapes
If Shape.HasChart Then
Set Chart = Shape.Chart
If Chart.ChartType = 53 Or Chart.ChartType = 59 Or Chart.ChartType = 57 Or Chart.ChartType = 52 Or Chart.ChartType = 58 Or Chart.ChartType = 5 Or Chart.ChartType = -4120 Then
RemoveSmallValues Chart
'For Each Series In Chart.SeriesCollection
If Chart.ChartType = 57 And Chart.HasAxis(xlCategory) Then
[B]Series.HasDataLabels = False[/B]
End If
End If
End If
Next Shape
Next Slide
End Sub
--------------------------------------
Code:
Sub RemoveSmallValues(Chart)
Const valueThreshold As Double = 0.05
For Each Series In Chart.SeriesCollection
' Series.HasDataLabels = False
Series.HasDataLabels = True
Dim pointCount As Integer
Dim pointValues As Variant
pointCount = Series.Points.Count
pointValues = Series.Values
For pointIndex = 1 To pointCount
If pointValues(pointIndex) < valueThreshold Then
Series.Points(pointIndex).HasDataLabel = False
Else
Series.Points(pointIndex).HasDataLabel = True
End If
Next pointIndex
Next Series
End Sub