Axes on chart in UserForm
- From: "Joe_Hunt via OfficeKB.com" <u45578@uwe>
- Date: Thu, 21 Aug 2008 15:30:19 GMT
I'm trying, with limited success, to put labels on the charts on both the X
and Y Axes I have in a UserForm, and to make the option buttons do the right
thing. Everything I've tried to put the labels in has errored out. Also, My
boss would like to be able to see either the 2008 product chart or the 2009
chart or both. I put option buttons, and they work, except when you switch
from one to the other it doesn't clear the other one, just adds to it,
meaning there is now one of each. If you click back on the first one you get
three, then four, and so on (I haven't even tried to make it go side-by-side
yet. I'm confused enough already). Below is the code behind one of the option
buttons. I would greatly, greatly appreciate any assistance.
Private Sub OptionButton1_Click()
If OptionButton1.Enabled = True Then
Dim ChtSpc As OWC11.ChartSpace
Dim cht As OWC11.ChChart
Dim Sps As OWC11.Spread***
Dim ws As Work***
Set ChtSpc = Me.ChartSpace1
Set Sps = Me.Spreadsheet1
Set ws = ThisWorkbook.Active*** ' change to your work*** name
Sps.Range("A1:AZ48") = ws.Range("A1:AZ48").Value ' Set work*** range to
*** control range
Set ChtSpc.DataSource = Sps ' set *** control as chart control source
Set cht = ChtSpc.Charts.Add ' Add blank chart
' Set data for chart
With cht
.SetData chDimCategories, 0, "C19:C46" ' change to your category
range
.SeriesCollection(0).SetData chDimValues, 0, "E19:E46" ' change to
your series 1 range
.SeriesCollection.Add
.SeriesCollection(1).SetData chDimValues, 0, "T19:T46" ' change to
your series 2 range
.SeriesCollection.Add
.SeriesCollection(2).SetData chDimValues, 0, "AJ19:AJ46" ' change to
your series 3 range
.HasTitle = True
.Title.Caption = Sps.Range("B5") ' change to your title cell
.Type = chChartTypeLine
.HasLegend = True
.SeriesCollection(0).Caption = "ALG"
.SeriesCollection(1).Caption = "Pros"
.SeriesCollection(2).Caption = "Recommended"
.Legend.Position = chLegendPositionBottom
.Legend.Interior.SetOneColorGradient chGradientHorizontal,
chGradientVariantCenter, 0.5, "White"
End With
' hide the *** control
Me.Spreadsheet1.Visible = False
' set the height of the chart control
Me.ChartSpace1.Height = 215
End If
End Sub
--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/excel-chart/200808/1
.
- Follow-Ups:
- Re: Axes on chart in UserForm
- From: Jon Peltier
- Re: Axes on chart in UserForm
- Prev by Date: Re: Triple column stacking chart
- Next by Date: Excel 2003 - chart with text categories in X and frequencies in Y
- Previous by thread: Triple column stacking chart
- Next by thread: Re: Axes on chart in UserForm
- Index(es):