用VBA更改图形的标题

时间:2016-05-17 17:24:22

标签: excel vba excel-vba

我对VBA很新。我有这段代码:

    Range("G37:G45").Select
    ActiveSheet.Shapes.AddChart2(201, xlColumnClustered).Select
    ActiveChart.SetSourceData Source:=Range("Analisis!$G$37:$G$45")
    ActiveChart.PlotArea.Select
    ActiveChart.FullSeriesCollection(1).XValues = "=Analisis!$H$37:$H$45"
    ActiveChart.FullSeriesCollection(1).Select
    ActiveChart.FullSeriesCollection(1).ApplyDataLabels

    ActiveChart.ChartTitle.Select
    ActiveChart.ChartTitle.Text = Sheets("Analisis").Range("F36")

基本上一切都有效但是当我在单元格F36中更改引用时,所有图形都会从标题中更改。我应该添加更多东西吗? 感谢

1 个答案:

答案 0 :(得分:0)

尝试:

ActiveChart.ChartTitle.Caption = "=Analisis!F36"