11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| Public Sub Chart_DataLabelsAdd(iSeriesNo As Integer, _ iColFirst As Integer, _ lRowFirst As Long, _ lRowLast As Long) Dim rgerange As Range Dim lcount As Long Dim snewlabel As String Dim lsmallest As Long ActiveChart.SeriesCollection(iSeriesNo).ApplyDataLabels Type:=xlDataLabelsShowLabel If ActiveChart.SeriesCollection(iSeriesNo).DataLabels.Count <= (lRowLast - lRowFirst + 1) Then lsmallest = ActiveChart.SeriesCollection(1).DataLabels.Count End If If (lRowLast - lRowFirst) <= ActiveChart.SeriesCollection(1).DataLabels.Count Then lsmallest = lRowLast - lRowFirst + 1 End If For lcount = 1 To lsmallest snewlabel = ActiveSheet.Cells(lRowFirst + lcount - 1, iColFirst).Value ActiveChart.SeriesCollection(iSeriesNo).DataLabels.Select ActiveChart.SeriesCollection(iSeriesNo).Points(lcount).DataLabel.Select Selection.Characters.Text = snewlabel Next lcount End Sub
|