|
-
May 12th, 2005, 05:49 AM
#1
Thread Starter
Junior Member
Creating charts in Excel with VBA, this code *should* work...
I'm hoping someone has an answer for this:
VB Code:
Private Sub CmdChart_Click()
'Create the new chart
Dim Newchart As Chart
Set Newchart = Charts.Add '(After:=Charts(Charts.Count))
'Change the Name
Newchart.Name = "Pipeline Summary"
'Create a series for the chart
Dim TheSeries As Series
Newchart.SeriesCollection.Add _
Source:=Worksheets("Pipeline").Range("K$12:N$50") 'chart data range
Set TheSeries = Newchart.SeriesCollection(1)
'Change the chart type
TheSeries.ChartType = xl3DPie
'Change the series title
TheSeries.Name = "Pipeline Info"
'Data formatting
With TheSeries
.XValues = _
Worksheets("Pipeline").Range("K$11:N$11") 'chart labels
.HasDataLabels = True
.DataLabels.ShowValue = True
.DataLabels.Font.Italic = True
.DataLabels.Font.Size = 14
End With
'Modify the legend
With Newchart
.HasLegend = True
.Legend.Font.Size = 14
End With
'modify the 3D view
With Newchart
.HasLegend = True
.Elevation = 45
End With
'format the chart title
With Newchart.ChartTitle
.Font.Bold = True
.Font.Size = 18
.Border.LineStyle = XlLineStyle.xlContinuous
.Border.Weight = XlBorderWeight.xlMedium
End With
'format the plot area
With Newchart.PlotArea
.Interior.Color = RGB(255, 255, 255)
.Border.LineStyle = XlLineStyle.xlLineStyleNone
.Height = 450
.Width = 450
.Top = 75
.Left = 25
End With
End Sub
The chart itself displays, but only contains the values of K12:K50, instead of everything from K12 - N50. I need it to display the SUM of the values in K12-K50, L12-L50, etc until N12-N50, then display those totals in the chart. Can someone help?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|