Labels and chart sheets

R

Revolveri

Hello

Is it possible to put a label (from the developer tools) on a chart sheet
and edit the caption VBA? I'd like to be able to display information on those
labels when I click on a data point on a chart.
 
J

Jon Peltier

Here's how to add a label with VBA:

Sub AddLabel()
' remove old label with same name
On Error Resume Next
ActiveChart.Shapes("MyLabel").Delete
On Error GoTo 0

ActiveChart.Shapes.AddShape(msoShapeRectangle, 75, 50, 125, 25).Name =
"MyLabel"
End Sub


And here's how to change what appears in the label:

Sub JustPopulateLabel()
With ActiveChart.Shapes("MyLabel").TextFrame
.Characters.Text = "Here's what I want to say."
End With
End Sub


- Jon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top