[英]Excel VBA - Insert chart from dynamic range
這是我使用的基本設置。 您可以添加許多格式來添加數據標簽,刪除網格線,更改標題等。您可以在進一步了解VBA之前考慮學習定義范圍。
Sub AddGraphs()
'Set the dynamic ranges
LR = Cells(Rows.Count, 1).End(xlUp).Row
LC = Cells(1, Columns.Count).End(xlToLeft).Column
'Create the chart
Charts.Add
With ActiveChart
.ChartType = xlColumnClustered
.SetSourceData Source:=Range(Cells(1, 1), Cells(LR, LC))
.Location xlLocationAsObject, "Sheet1"
End With
'Format chart and set location
With ActiveChart
.Parent.Top = Cells(1, LC + 3).Top
.Parent.Left = Cells(1, LC + 3).Left
.HasLegend = False
End With
End Sub
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.