adventurer
New Member
- Joined
- Jul 1, 2015
- Messages
- 9
Hi,
This is the part of the large data set I have. I want to plot two separate charts for the 'Actual' and '% of total'.
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
This is the code I have. It gives me the Actual and % plots in same chart. I have tried codes for selecting alternate columns and plotting two charts but did not work.
This is the chart I got. Kindly suggest me a code to make two separate charts for alternate columns one for 'Actual' and the other for '% of total' values.