Macro code to put series name next to individual line in line grap

O

Otani

I want to put the series names next to their corresponding line in the line
graph. I remember seeing on the internet that there is a macro code for this
but I cannot find this anymore. Does anyone know what the macro code is?
 
O

Otani

I have used the VBA code from the John Peltier link at the bottom. The macro
works but for some reason everytime I change the series name in the table,
the legend in the graph would automatically change as well but the label next
to the graph doesn't. I have to run the macro again to see the change takes
effect. My macro setting is already set to enable all so I don't if I have
missed something.
 
J

Jon Peltier

The original code created a static label populated by the text that was
the series name when the label was created. Change the series name, the
label does not change.

Modify the ApplyDataLabels command to this:

mySrs.Points(iPts).ApplyDataLabels _
ShowSeriesName:=True, ShowCategoryName:=False, _
ShowValue:=False, AutoText:=False, LegendKey:=False

The label now explicitly shows the series name. Change the series name,
and the label itself changes.

I updated the tutorial when Excel 2007 misbehaved. The new version works
in all versions, and includes the above enhancement:

Label Last Point for Excel 2007 » Peltier Tech Blog
http://peltiertech.com/WordPress/label-last-point-for-excel-2007/

- 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