![](/img/trans.png)
[英]Excel VBA Combo Chart with different Excel versions (2010 vs 2016)
[英]Creating a combo chart in Excel with VBA code
如何調整下面的代碼以創建一個組合圖表,其中主軸的條形和輔助軸的條形圖?
我有兩列數據。
Sub CreateChart()
Dim rng As Range
Dim cht As Object
Set rng = ActiveSheet.Range("C1:D6")
Set cht = ActiveSheet.Shapes.AddChart2
cht.Chart.SetSourceData Source:=rng
cht.Chart.ChartType = xlColumnClustered
cht.Chart.HasTitle = True
cht.Chart.ChartTitle.Text = "Average Price and Dollar Volume of Sales"
End Sub
任何幫助,將不勝感激! 謝謝!
這個怎么樣:
Sub foo()
ActiveSheet.Shapes.AddChart2(201, xlColumnClustered).Select
ActiveChart.SetSourceData Source:=Range("Sheet1!$C$1:$D$6") 'make sure the range is correct here
ActiveChart.FullSeriesCollection(1).ChartType = xlColumnClustered 'select which column should be the Line or the Column
ActiveChart.FullSeriesCollection(1).AxisGroup = 1
ActiveChart.FullSeriesCollection(2).ChartType = xlLine
ActiveChart.FullSeriesCollection(2).AxisGroup = 1
ActiveChart.ChartTitle.Text = "Average Price and Dollar Volume of Sales"
End Sub
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.