how to add data label to bubble chart in excel

前端 未结 2 1388
庸人自扰
庸人自扰 2021-01-24 18:23

Hi I want to add customize data label to my bubble chart. my code is below. at the moment data label refer to XValues. I would like my data label fill with bubble size. would u

相关标签:
2条回答
  • 2021-01-24 18:42

    DataLabel.Text is a method for a Point, not the NewSeries

    This code:

    For r = 2 To Selection.Rows.Count
        With bubbleChart.Chart.SeriesCollection.NewSeries
            [...]
            .DataLabel.Text = "txt"
        End With 
    Next
    

    ...attempts to label the series, and fails.

    Recognizing this code as being from another famous example of "multi-series Bubble Charts", it is a logical assumption that we only need to handle 1 data point per series, which makes the following code the solution:

    For r = 2 To Selection.Rows.Count
        With bubbleChart.Chart.SeriesCollection.NewSeries
            [...]
            .Points(1).HasDataLabel = True
            .Points(1).DataLabel.Text = "txt"
        End With 
    Next
    
    0 讨论(0)
  • 2021-01-24 19:02

    Without using VBA, right click on the bubbles and select Add Data Labels. Then, right click on the data labels and click Format Data Labels. Under Label Options, select Value From Cells and specify the cells containing the labels you'd like to use.

    0 讨论(0)
提交回复
热议问题