VBA代码绘制两个单独的图表替代列

这是我拥有的大数据集的一部分。 我想为“实际”和“总量的百分比”绘制两个单独的图表。

这是我目前的代码:

Private Sub CommandButton2_Click() Dim ChartRange1 As Range Dim ChartRange2 As Range `StrtRow = 1 StartRow = 3 EndRow = 6 With Sheets("Sheet1") Set ChartRange1 = Range(Cells(StrtRow, "B"), Cells(EndRow, "B")) ChartRange1Addr = ChartRange1.Address(External:=True) Set ChartRange2 = Range(Cells(StrtRow, "C"), Cells(EndRow, "J")) ChartRange2Addr = ChartRange2.Address(External:=True) End With ActiveSheet.Shapes.AddChart.Select 'We set the source data for the chart (y,x) ActiveChart.SetSourceData Source:=Range( _ ChartRange1Addr & "," & ChartRange2Addr) 'We define the type of chart ActiveChart.ChartType = xlColumnClustered ' Before we can perform an action on the chart we need to activate it ActiveSheet.ChartObjects(1).Activate 'We perform the cut operation ActiveSheet.ChartObjects(1).Cut 'we select the Sheet2 where we wish to paste our chart Sheets("Sheet2").Select 'We now paste the chart in the Sheet2 whic has become the active sheet after selection ActiveSheet.Paste 'we return to sheet1 Sheets("Sheet1").Select ' we select the cell F9 in sheet1 Range("F9").Activate End Sub 

它给了我同样的图表中的实际和百分比图。 我已经尝试了用于select备用列和绘制两个图表的代码,但没有奏效。

这是我得到的图表。 请build议我可以在哪里修改我的代码,为备用列创build两个单独的图表 – 一个用于“实际”,另一个用于“总数”值。