Add callout to line graph (last point only)

smak

New Member
Joined
Mar 18, 2022
Messages
32
Office Version
  1. 2010
Platform
  1. Windows
I have a line graph. I want to put a call out on the last point on the chart. I can get it to put a data point (just the % of the point) but not a call out.

what works to get the data point on the graph is below. this macro selects the last point on the graph and adds the data label.
VBA Code:
Sub z6_fix_callouts()

 Dim menckPoints As Points
 Dim I As Integer
 Dim NumPoints As Long
     
 '****open tab and chart****
    Sheets("Alaska Epi Curve").Select
    ActiveSheet.ChartObjects("Chart 4").Activate
      
'****select last point on graph****
    Set menckPoints = ActiveChart.FullSeriesCollection(7).Points
        menckPoints(menckPoints.Count).Select
        
'****add data label****
    NumPoints = menckPoints.Count
    ActiveChart.FullSeriesCollection(7).Points(NumPoints).[B][COLOR=rgb(184, 49, 47)]ApplyDataLabels[/COLOR][/B]

End Sub

what would be the syntax for the .ApplyDataLabels portion that would put the call out bubble instead of just a data label
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
i'd do something with the last answer in this threat
VBA Code:
Sub Macro9()
    ActiveSheet.ChartObjects("SPC").Activate
    ActiveChart.SeriesCollection(1).Points(4).HasDataLabel = True
    ActiveChart.SeriesCollection(1).Points(4).DataLabel.Text = "Point 4 Test"
End Sub
 
Upvote 0
A callout is a data label with some kind of shape, not just a text box. Use bits of this sub to get what you want. Note that you want to remove the default leader lines, which would be redundant, and you have to make the border visible, because when you first change the shape, it has the same border as the textbox, which is none (and this confused me for several minutes).

VBA Code:
Sub ChangeDataLabelShape()
  With ActiveChart.SeriesCollection(1)
    .HasLeaderLines = False
    With .Points(1).DataLabel
      .Format.AutoShapeType = msoShapeRectangularCallout
      .Format.Line.Visible = True
    End With
  End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,861
Messages
6,121,973
Members
449,059
Latest member
oculus

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