Excel VBA – Pivot table/chart 4 – Chart type control

Changing Chart Type using VBA code

Sample file downloadhttps://github.com/dannyyun/pivot-vba.git

Changing Chart type (line chart, stacked column, 100% stacked column)

Sub ChtType()

    With ActiveSheet.Shapes("Drop Down 4").ControlFormat

        Select Case .ListIndex
            Case Is = 1
                ActiveSheet.ChartObjects("Chart 1").Activate
                ActiveChart.ChartType = xlLine
                ActiveSheet.Range("A1").Select
                
            Case Is = 2
                ActiveSheet.ChartObjects("Chart 1").Activate
                ActiveChart.ChartType = xlColumnStacked
                ActiveSheet.Range("A1").Select
                
            Case Is = 3
                ActiveSheet.ChartObjects("Chart 1").Activate
                ActiveChart.ChartType = xlColumnStacked100
                ActiveSheet.Range("A1").Select
                
        End Select
    End With

End Sub

Leave a Reply

Discover more from this and that @ work

Subscribe now to keep reading and get access to the full archive.

Continue reading