Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You are getting errors. Remove the statement "On Error Resume Next" and try
running your code again. The errors are your problem. Also change your VBA setting in the menu Tools - Options - general - Stop on all errors. This should help you find the real problems. "Michael Hudston" wrote: Has anyone got any idea's why my Charts are not displaying any titles? I would be apreciative of any suggestions Thanks Mike Code Below Sub Draw_Chart_Click() On Error Resume Next Dim chtChart As Chart Dim Pt As Point Dim Ser Dim arr Dim arr2 Dim i Dim chtSlct As String chtSlct = Trim(Range("B5").Value) ' Remove Existing Chart ActiveSheet.ChartObjects.Delete ' Create a new chart. arr = Array(RGB(83, 142, 213), RGB(149, 179, 213), RGB(217, 151, 149), RGB(194, 214, 154), RGB(178, 161, 199), RGB(147, 205, 221), RGB(250, 192, 144), RGB(23, 55, 93), RGB(55, 96, 145), RGB(149, 55, 53), RGB(117, 146, 60), RGB(96, 73, 123)) i = -1 Set chtChart = Charts.Add Set chtChart = chtChart.Location(Whe=xlLocationAsObject, Name:="CHARTS") ' Choose Which Chart to Plot If chtSlct = Range("B101").Value Then ' Set Description Range("B16").Value = Range("H101").Value ' Set Colour Scheme for Chart With chtChart ' Set Chart Type .ChartType = xlCylinderCol ' Set data source range. .SetSourceData Source:=Sheets("BASIC CHART DATA").Range("L11:X14"), PlotBy:=xlRows .HasTitle = True .ChartTitle.Text = "Incident Age (From Occurence to Closure)" .SeriesCollection(1).XValues = "='BASIC CHART DATA'!$M$4:$X$10" .SeriesCollection(1).Interior.Color = RGB(0, 255, 0) .SeriesCollection(2).Interior.Color = RGB(255, 255, 0) .SeriesCollection(3).Interior.Color = RGB(255, 180, 0) .SeriesCollection(4).Interior.Color = RGB(255, 0, 0) ' The Parent property is used to set properties of the Chart, in this case the location on the sheet. With .Parent .Top = Range("G2").Top .Left = Range("G2").Left .Width = Range("G2:S31").Width .Height = Range("G2:S31").Height End With End With ElseIf chtSlct = Range("B100").Value Then ' Set Description Range("B16").Value = Range("H100").Value With chtChart .ChartType = xlCylinderColClustered ' Set data source range. .SetSourceData Source:=Sheets("Trend Analysis").Range("K5:V5, K2006:V2006"), PlotBy:=xlRows .HasTitle = True .ChartTitle.Text = "Number of Incidents by LRU" With .Parent .Top = Range("G2").Top .Left = Range("G2").Left .Width = Range("G2:S31").Width .Height = Range("G2:S31").Height End With End With For Each Pt In chtChart.SeriesCollection(1).Points i = i + 1 If i <= UBound(arr) Then Pt.Interior.Color = arr(i) Next ElseIf chtSlct = Range("B102").Value Then ' Set Description Range("B16").Value = Range("H102").Value With chtChart .ChartType = xlCylinderCol ' Set data source range. .SetSourceData Source:=Sheets("BASIC CHART DATA").Range("H76:I79"), PlotBy:=xlRows .ChartTitle.Text = "Severity (SRB V User)" .SeriesCollection(1).XValues = "='BASIC CHART DATA'!$H$75:$I$75" .SeriesCollection(1).Name = "='BASIC CHART DATA'!$G$76" .SeriesCollection(2).Name = "='BASIC CHART DATA'!$G$77" .SeriesCollection(3).Name = "='BASIC CHART DATA'!$G$78" .SeriesCollection(4).Name = "='BASIC CHART DATA'!$G$79" .SeriesCollection(1).Interior.Color = RGB(255, 0, 0) 'Critical .SeriesCollection(2).Interior.Color = RGB(255, 180, 0) ' Major .SeriesCollection(3).Interior.Color = RGB(255, 255, 0) ' Minor .SeriesCollection(4).Interior.Color = RGB(0, 255, 0) ' Not Relevant ' The Parent property is used to set properties of the Chart. With .Parent .Top = Range("G2").Top .Left = Range("G2").Left .Width = Range("G2:S31").Width .Height = Range("G2:S31").Height End With End With ElseIf chtSlct = Range("B103").Value Then ' Set Description Range("B16").Value = Range("H103").Value With chtChart .ChartType = xlCylinderCol ' Set data source range. .SetSourceData Source:=Sheets("BASIC CHART DATA").Range("H49:H60") .HasTitle = True .ChartTitle.Text = "Incidents by Cause" .SeriesCollection(1).XValues = "='BASIC CHART DATA'!$G$49" .SeriesCollection(1).Name = "='BASIC CHART DATA'!$G$49" .SeriesCollection(2).XValues = "='BASIC CHART DATA'!$G$50" .SeriesCollection(2).Name = "='BASIC CHART DATA'!$G$50" .SeriesCollection(3).XValues = "='BASIC CHART DATA'!$G$51" .SeriesCollection(3).Name = "='BASIC CHART DATA'!$G$51" .SeriesCollection(4).XValues = "='BASIC CHART DATA'!$G$52" .SeriesCollection(4).Name = "='BASIC CHART DATA'!$G$52" .SeriesCollection(5).XValues = "='BASIC CHART DATA'!$G$53" .SeriesCollection(5).Name = "='BASIC CHART DATA'!$G$53" .SeriesCollection(6).XValues = "='BASIC CHART DATA'!$G$54" .SeriesCollection(6).Name = "='BASIC CHART DATA'!$G$54" .SeriesCollection(7).XValues = "='BASIC CHART DATA'!$G$55" .SeriesCollection(7).Name = "='BASIC CHART DATA'!$G$55" .SeriesCollection(8).XValues = "='BASIC CHART DATA'!$G$56" .SeriesCollection(8).Name = "='BASIC CHART DATA'!$G$56" .SeriesCollection(9).XValues = "='BASIC CHART DATA'!$G$57" .SeriesCollection(9).Name = "='BASIC CHART DATA'!$G$57" .SeriesCollection(10).XValues = "='BASIC CHART DATA'!$G$58" .SeriesCollection(10).Name = "='BASIC CHART DATA'!$G$58" .SeriesCollection(11).XValues = "='BASIC CHART DATA'!$G$59" .SeriesCollection(11).Name = "='BASIC CHART DATA'!$G$59" .SeriesCollection(12).XValues = "='BASIC CHART DATA'!$G$60" .SeriesCollection(12).Name = "='BASIC CHART DATA'!$G$60" With .Parent .Top = Range("G2").Top .Left = Range("G2").Left .Width = Range("G2:S31").Width .Height = Range("G2:S31").Height End With End With ElseIf chtSlct = Range("B104").Value Then ' Set Description Range("B16").Value = Range("H104").Value With chtChart .ChartType = xlCylinderCol ' Set data source range. .SetSourceData Source:=Sheets("BASIC CHART DATA").Range("H63:H66") .HasTitle = True .ChartTitle.Text = "Number of Incidents by Liability" .SeriesCollection(1).XValues = "='BASIC CHART DATA'!$G$63" .SeriesCollection(1).Name = "='BASIC CHART DATA'!$G$63" .SeriesCollection(1).Interior.Color = RGB(255, 0, 0) .SeriesCollection(2).XValues = "='BASIC CHART DATA'!$G$64" .SeriesCollection(2).Name = "='BASIC CHART DATA'!$G$64" .SeriesCollection(2).Interior.Color = RGB(0, 255, 0) .SeriesCollection(3).XValues = "='BASIC CHART DATA'!$G$65" .SeriesCollection(3).Name = "='BASIC CHART DATA'!$G$65" .SeriesCollection(3).Interior.Color = RGB(0, 0, 255) .SeriesCollection(4).XValues = "='BASIC CHART DATA'!$G$66" .SeriesCollection(4).Name = "='BASIC CHART DATA'!$G$66" .SeriesCollection(4).Interior.Color = RGB(255, 255, 0) With .Parent .Top = Range("G2").Top .Left = Range("G2").Left .Width = Range("G2:S31").Width .Height = Range("G2:S31").Height End With End With ActiveChart.Axes(xlCategory).Select Selection.Delete ElseIf chtSlct = Range("B105").Value Then ' Set Description Range("B16").Value = Range("H105").Value With chtChart .ChartType = xlCylinderCol ' Set data source range. .SetSourceData Source:=Sheets("BASIC CHART DATA").Range("G34:H39") .HasTitle = True .ChartTitle.Text = "Current Status" .SeriesCollection.XValues = "='BASIC CHART DATA'!$G$34:$G$39" .SeriesCollection.Name = "='BASIC CHART DATA'!$G$34:$G$39" .SeriesCollection(1).Interior.Color = RGB(255, 0, 0) 'Open .SeriesCollection(2).Interior.Color = RGB(255, 180, 0) ' Under Investigation .SeriesCollection(3).Interior.Color = RGB(0, 128, 0) 'Corrective Action .SeriesCollection(4).Interior.Color = RGB(255, 0, 0) ' Deferred .SeriesCollection(5).Interior.Color = RGB(128, 255, 0) ' SRB .SeriesCollection(6).Interior.Color = RGB(0, 255, 0) ' Closed ActiveChart.Axes(xlCategory).Select Selection.Delete ' The Parent property is used to set properties of the Chart. With .Parent .Top = Range("G2").Top .Left = Range("G2").Left .Width = Range("G2:S31").Width .Height = Range("G2:S31").Height End With End With ElseIf chtSlct = Range("B106").Value Then ' Set Description Range("B16").Value = Range("H106").Value With chtChart .ChartType = xlCylinderCol ' Set data source range. .SetSourceData Source:=Sheets("BASIC CHART DATA").Range("G34:H39") .HasTitle = True .ChartTitle.Text = "Current Status" .SeriesCollection.XValues = "='BASIC CHART DATA'!$G$34:$G$39" .SeriesCollection.Name = "='BASIC CHART DATA'!$G$34:$G$39" .SeriesCollection(1).Interior.Color = RGB(255, 0, 0) 'Open .SeriesCollection(2).Interior.Color = RGB(255, 180, 0) ' Under Investigation .SeriesCollection(3).Interior.Color = RGB(0, 128, 0) 'Corrective Action .SeriesCollection(4).Interior.Color = RGB(255, 0, 0) ' Deferred .SeriesCollection(5).Interior.Color = RGB(128, 255, 0) ' SRB .SeriesCollection(6).Interior.Color = RGB(0, 255, 0) ' Closed ActiveChart.Axes(xlCategory).Select Selection.Delete |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Chart Titles - Thanks | Excel Programming | |||
Chart titles | Excel Programming | |||
Chart Titles not showing in excel chart | Excel Discussion (Misc queries) | |||
Chart Titles not showing in excel chart Window | Excel Discussion (Misc queries) | |||
Centering Axis and Chart Titles on chart | Excel Discussion (Misc queries) |