LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Column-line chart on two axes Mary Ann Charts and Charting in Excel 2 October 6th 08 07:18 PM
Column Chart with 2 axes Greenfield Charts and Charting in Excel 7 May 26th 08 02:57 AM
Column chart with two axes Greenfield Charts and Charting in Excel 1 May 19th 08 07:59 PM
Two-Column, Two Axes Chart Michael Charts and Charting in Excel 1 December 7th 05 06:17 PM
I need a customized Excel chart: Column - Column on 2 Axes S. Middendorf Charts and Charting in Excel 2 July 13th 05 03:13 PM


All times are GMT +1. The time now is 02:45 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"