November 5th, 2003, 6:05 pm
I need small help related to labeling datapoints in XY charts in excel. I want to make a VB macro for labeling each data points that are split into 8 different series. Each data point has a x, y as in excel but they are numeric values. I need to add a specific name to each datapoint from a column of 58 names in excel spread sheet. Can anyone give a basic infrastructure of the code to be used in vb for the same. It will automate the labeling business, rather than using external add-ins or doing by hand. Someone proposed this code, which I modified. Having some syntax problem in the macro, in the line "Cht.SeriesCollection(j).Points(i).DataLabel.Charachters.Text = TextRange(k) " I have also uploaded the excel sheet to run the macro named "AddLabels" The factors are in the sheet currentmonthsummary and are categorized . The graph is currentmonthgraph and has the datapoints that need to be labeled accordingly. Someone, have a look and please correct. Am new to VB. Sub Addlabels()Dim TextRange As RangeSet TextRange = Sheets("currentmonthsummary").Range("A2:A60") 'assign the rangeNoOfDataSeries = 8NoOfPoints = 7For j = 1 To NoOfDataSeriesFor i = 1 To NoOfPointsSheets("currentmonthgraph").Selectk = (j - 1) * NoOfPoints + i + OffsetActiveChart.SeriesCollection(j).Points(i).DataLabels.Characters.Text = TextRange(k)Next iNext jEnd Sub