PDA

View Full Version : Let user choose chart type



chapster21
12-09-2008, 07:49 PM
I have attached the program that I am working on. I need to add a userform that lets the user choose between two different types of charts that they want displayed for each button choice. I have tried the below code but it does not work.


Option Explicit
Public choice As Chart

Private Sub CommandButton1_Click()
With choice
Charts.Add
If OptionButton1 Then

ActiveChart.ChartType = xlColumnClustered
Else: ActiveChart.ChartType = xlConeCol
End If
End With
Unload Me
End Sub

Private Sub CommandButton2_Click()
Unload Me
End Sub

Bob Phillips
12-10-2008, 01:57 AM
What doesn't work about it? I plugged it into a workbook and generated the charts fine.

chapster21
12-10-2008, 06:20 PM
The attachment did not have the code that I pasted. There is not a choice of charts on the attachment. If a userform "frmChartType" is created with two radio buttons and then there is a reference in the MainBlending sub to the public variable in the frmChartType OK button, it should work. There has to be a loop in the Mainblending sub to loop through all of the buttons on the report worksheet to give the user the choice of chart types that they want displayed.

Bob Phillips
12-11-2008, 01:19 AM
No there isn'y, but I created a workbook with that code and it worked. So the principle is ok, if yours doesn't work it must be something else. But as I said, you say it doesn't work, but not what, not where it is failing. So we can only go so far talking in abstracts.