我正在尝试创建一个动态饼图。以下代码仅对固定范围起作用。我的问题是我必须从最后使用的行中获取数据并将其作为图表的输入。我无法更改图表中的标签。
Sub Chart()
With ActiveSheet.ChartObjects.Add(Left:=440, Width:=310, Top:=475, Height:=200)
With .Chart
.SetSourceData Source:=ActiveSheet.Range("G16:K16")
.ChartType = xl3DPie
.HasTitle = True
.ApplyDataLabels Type:=xlDataLabelsShowLabelAndPercent
.ChartTitle.Characters.text = "Summary Report"
.ChartTitle.Characters.Font.Size = 10
.ChartTitle.Characters.Font.Bold = True
.HasLegend = False
.RightAngleAxes = True
With .ChartArea
With .Border
.Weight = 2
.LineStyle = 0
End With
With .Interior
.ColorIndex = 39
.PatternColorIndex = 1
.Pattern = 1
End With
End With
With .PlotArea
With .Border
.Weight = 2
.LineStyle = 0
End With
With .Interior
.ColorIndex = 39
.PatternColorIndex = 1
.Pattern = 1
End With
End With
End With
End With
End Sub
还有一件事是我希望将图表放在最后一行之后的三行