MrExcel Publishing
Your One Stop for Excel Tips & Solutions

label data points with more data


Posted by Megan on January 07, 2002 12:22 PM

I need some help-
I was wondering if it was possible to label or color data points with other data. For example we have data that is collected by people, so we have their initials in the worksheet. I was wondering if it was possible to label each point with the initial or have a different color for each person. Does this make sense?
Thanks in advance


Posted by Damon Ostrander on January 07, 2002 12:54 PM

Hi Megan,

Here's an example of a macro that labels the chart data from a range of cells. This example is for a chart where the x and y axes get their data from columns B and C, and the labels are derived from columns A and B.

If you would like me so email you a copy of the workbook, just follow up with a post that includes your email address.

Here's the code:

Sub AddLabels()

With Worksheets(1).ChartObjects(1).Chart
ActiveWindow.Visible = False
ActiveWindow.Activate
For i = 1 To .SeriesCollection(1).Points.Count
With .SeriesCollection(1).Points(i)
.HasDataLabel = True
.DataLabel.Text = Cells(i, 1) & vbCr & Cells(i, 4)
End With
Next i
End With

End Sub

Happy labelling,

Damon

Posted by Megan on January 07, 2002 1:00 PM

That sounds great! Thanks so much for your speedy reponse. If you could email the workbook to me at mshill@iastate.edu that would be wonderful!
Thanks again!!!