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
Last edited by Aland2929; 07-23-2009 at 12:00 PM.
What does the Range("unitsORrands") contain?
If it's 1 then it should do the first part of your code.
If not then it will do nothing as you have a Exit Sub in the middle of your code.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks