Please Register to Remove these Ads
Hi All,
My chart was working until I introduced two options buttons to determine the data to plot (units or value). When I run the code a chart is not displayed?
Please help.
Thank You.
Code:
Sub CreateChart()
Dim unitsORrands As Integer
' Choose data to plot
If Range("unitsORrands") = 1 Then
' Create chart with UNIT data
Range("UnitChartData").Select
Range("C337").Activate
ActiveSheet.Shapes.AddChart.Select
ActiveChart.SetSourceData Source:=Range("UnitChartData")
ActiveChart.ChartType = xlLine
ActiveChart.ClearToMatchStyle
ActiveChart.ChartStyle = 42
ActiveChart.ClearToMatchStyle
ActiveChart.SetElement (msoElementChartTitleAboveChart)
ActiveChart.ChartTitle.Text = "=BranchName"
Range("BranchChosen").Select
End If
Exit Sub
If Range("unitsORrands") = 2 Then
' Create chart with RAND data
Range("RandChartData").Select
Range("C337").Activate
ActiveSheet.Shapes.AddChart.Select
ActiveChart.SetSourceData Source:=Range("RandChartData")
ActiveChart.ChartType = xlLine
ActiveChart.ClearToMatchStyle
ActiveChart.ChartStyle = 42
ActiveChart.ClearToMatchStyle
ActiveChart.SetElement (msoElementChartTitleAboveChart)
ActiveChart.ChartTitle.Text = "=BranchName"
Range("BranchChosen").Select
End If
End Sub