The missing slash

a short note for a useful excel macro

Posted in excel, Things I learned today by hhs on October 26, 2010

Yesterday I wanted to make a scatterplot with excel, but this brilliant program is not able to put labels on the dots (unless you are really bored and want to assign each one manually). It is quite easy to find a macro for this problem if you search for it, but I find most of them way too complicated. And yestreday I was not able to find or recreate the one I once used, but now I managed. So here it is (and next time I know where to look for it):


Sub AddLabels()
Dim RngLabels As Range
Dim Ser As Series
Dim i As Long
If TypeName(Selection) = “Series” Then
Set Ser = Selection
Set RngLabels = Application.InputBox(prompt:=”Select the label range:”, Type:=8)
Ser.HasDataLabels = True
For i = 1 To Ser.Points.Count
Ser.Points(i).DataLabel.Text = RngLabels(i)
Next i
Else
MsgBox “Select a series”
End If
End Sub

I did not write it myself but don’t know where I have copied it from (but many thanks to the original author). For openoffice users I can happily say, that you don’t need a macro, the program is clever enough to have this function…

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.