Not sure if it's possible with VBA but I would like to use each part of a pie chart as buttons to run four different macros.
Furthermore, the pie chart is re-created every time (code shown below) when the values changes and so the sizes of the slices isn't fixed. As such, I don't think I can just put a similar shape on top of the slices and assign a macro to it.
Public Sub CreatePieChart()
Dim ws As Worksheet
Dim ch_shape As Shape
Dim lab As DataLabel
Dim x As Long, y As Long, w As Long, h As Long
Dim circ As Shape
Set ws = ThisWorkbook.Worksheets("Sheet1")
Set ch_shape = ws.Shapes.AddChart2
With ch_shape.Chart
With .ChartArea
.Format.Fill.ForeColor.RGB = RGB(244, 244, 244)
.Height = 300
.Width = 450
.Left = 0
.Top = 350
End With
.ChartType = xlPie
.SetSourceData ws.Range("D14:E17")
.HasTitle = False
.HasLegend = False
.ApplyDataLabels xlDataLabelsShowLabel, , , , , True, , True, , vbLf
With .FullSeriesCollection(1).DataLabels
.Position = xlLabelPositionOutsideEnd
.NumberFormat = "0.0%"
End With
End With
End Sub