Announcement

Collapse
No announcement yet.

Changing First Slice Angle of a Pie Chart based on cell reference

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Changing First Slice Angle of a Pie Chart based on cell reference



    I have a series of Pie charts arranged around a circle and I would like to be able to toggle the start angle of the first slice using a drop down that I've already created.

    Here's my code:
    Code:
    Public Sub RotateSeries(ByVal Target As Range)
    '
    ' RotateSeries Macro
    '
    
    
    If Target.Address = "$P$10" Then
       Select Case Target.Text
        '   Select Case Target.Range("$P$10").Value
            Case Is = "0 Start"
                ActiveSheet.ChartObjects("Chart 37").Activate
                ActiveChart.ChartGroups(1).FirstSliceAngle = 0
            Case Is = "Rotate"
                ActiveSheet.ChartObjects("Chart 37").Activate
                ActiveChart.ChartGroups(1).FirstSliceAngle = 270
        End Select
        
        End If
    End Sub
    I recorded a macro to select the chart series and manually change it and then tried to create this based off of it. My drop down only has the two values "0 Start" and "Rotate"

    Thanks in advance for the help.

    Michael
    Last edited by AAE; June 25th, 2013, 09:13. Reason: add code tags

  • #2


    Re: Changing First Slice Angle of a Pie Chart based on cell reference

    Welcome to Ozgrid.

    Please read the forum rules and learn to use code tags.

    All VBA code posted in the forum must be wrapped in code tags, which you omitted, including single-line code snippets.
    I've added the tags for you this time only. Be sure to use them in future posts.

    How to use code tags

    [code]
    your code goes between these tags
    [/code]

    Or, just highlight all of the code and press the # button to add the code tags

    Here is the idea:
    Code:
    ActiveChart.ChartGroups(1).FirstSliceAngle = ActiveSheet.Range("A1").value
    Change your drop down to contain true numbers, adjust the range reference accordingly.
    AAE
    ----------------------------------------------------

    Forum Rules | Message to Cross Posters | How to use Tags

    Comment

    Working...
    X