Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Column Chart with two axes
I would like a macro to create a chart with twin columns but different axes.
I have recorded a macro using "Line - Column on 2 Axes" which is the closest towhat Iwant but when I run it, the code fails. (Excel 2003) Here is the code with a comment at the point where it falls over: Sub ChartTest() Dim sel As Range, sel2 As Range [a1] = "Causes" [b1] = "Roll Changes" [c1] = "Strip Breaks" [d1] = "Cobbles" [a2] = "Time Lost" [b2] = 220 [c2] = 64 [d2] = 5 [a3] = "Occurences" [b3] = 12 [c3] = 4 [d3] = 1 Columns("A:D").EntireColumn.AutoFit Set sel = Range("A1:D2") Set sel2 = Range("A3:D3") ' had to add Activeworkbook to next line ActiveWorkbook.Charts.Add ActiveChart.ApplyCustomType ChartType:=xlBuiltIn, TypeName:= _ "Line - Column on 2 Axes" ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("A1:D3"), PlotBy:= _ xlRows ActiveChart.Location Whe=xlLocationAsObject, name:="Sheet1" With ActiveChart .HasTitle = True .ChartTitle.Characters.Text = "Delay Causes" .Axes(xlCategory, xlPrimary).HasTitle = False .Axes(xlValue, xlPrimary).HasTitle = True .Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Time Lost (min)" ' fails on next line .Axes(xlCategory, xlSecondary).HasTitle = False ' fails here .Axes(xlValue, xlSecondary).HasTitle = True .Axes(xlValue, xlSecondary).AxisTitle.Characters.Text = "Occurences" End With ActiveChart.HasLegend = False ActiveChart.HasDataTable = True ActiveChart.DataTable.ShowLegendKey = True ActiveChart.Axes(xlValue, xlSecondary).Select With ActiveChart.Axes(xlValue, xlSecondary) .MinimumScaleIsAuto = True .MaximumScale = .MaximumScale * 2 .MinorUnitIsAuto = True .MajorUnitIsAuto = True .Crosses = xlAutomatic .ReversePlotOrder = False .ScaleType = xlLinear .DisplayUnit = xlNone End With End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Column-line chart on two axes | Charts and Charting in Excel | |||
Column Chart with 2 axes | Charts and Charting in Excel | |||
Column chart with two axes | Charts and Charting in Excel | |||
Two-Column, Two Axes Chart | Charts and Charting in Excel | |||
I need a customized Excel chart: Column - Column on 2 Axes | Charts and Charting in Excel |