Urgent - Help Needed for PowerPoint Macro - Multiple If condition

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.

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
 
Does this help?

Code:
[COLOR=darkblue]Sub[/COLOR] RemoveSmallValuesFromExecutiveReportCharts()
    [COLOR=darkblue]For[/COLOR] [COLOR=darkblue]Each[/COLOR] Slide [COLOR=darkblue]In[/COLOR] ActivePresentation.Slides
        [COLOR=darkblue]For[/COLOR] [COLOR=darkblue]Each[/COLOR] Shape [COLOR=darkblue]In[/COLOR] Slide.Shapes
            [COLOR=darkblue]If[/COLOR] Shape.HasChart [COLOR=darkblue]Then[/COLOR]
                [COLOR=darkblue]Set[/COLOR] Chart = Shape.Chart
                [COLOR=darkblue]Select[/COLOR] [COLOR=darkblue]Case[/COLOR] Chart.ChartType
                    [COLOR=darkblue]Case[/COLOR] 57
                        [COLOR=darkblue]If[/COLOR] Chart.HasAxis(xlCategory) [COLOR=darkblue]Then[/COLOR]
                            [COLOR=darkblue]For[/COLOR] [COLOR=darkblue]Each[/COLOR] Series [COLOR=darkblue]In[/COLOR] Chart.SeriesCollection
                                Series.HasDataLabels = [COLOR=darkblue]False[/COLOR]
                            [COLOR=darkblue]Next[/COLOR] Series
                        [COLOR=darkblue]Else[/COLOR]
                            RemoveSmallValues Chart
                        [COLOR=darkblue]End[/COLOR] [COLOR=darkblue]If[/COLOR]
                    [COLOR=darkblue]Case[/COLOR] 53, 59, 52, 58, 5, -4120
                        RemoveSmallValues Chart
                [COLOR=darkblue]End[/COLOR] [COLOR=darkblue]Select[/COLOR]
             [COLOR=darkblue]End[/COLOR] [COLOR=darkblue]If[/COLOR]
        [COLOR=darkblue]Next[/COLOR] Shape
    [COLOR=darkblue]Next[/COLOR] Slide
[COLOR=darkblue]End[/COLOR] [COLOR=darkblue]Sub[/COLOR]
 
Upvote 0

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

Forum statistics

Threads
1,217,304
Messages
6,135,730
Members
449,960
Latest member
ubergreen

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top