Hi!
I encounter problems in obtaining a macro that inserts a "Line-column on 2 Axes" chart. The manual procedure always works and produces nice graphs but the code obtained by macro recorder always fails to work. After several attempts and variants I could say that implementing the secondary graph is the problem.
Here is the code (one of several variants which I tried):
REMARKS:
------------
Whenever trying to run the macro, one obtains the following message:
and the code line which throws that message is
Any other variant (including "False" choices instead of "True") yields identical effect at the same line, that is the first code line which concerns the secondary graph.
If asking for help (in the debug assistant form) then the systems opens an empty help form and then hangs until closing that empty form.
I've googled on this matter and discovered few similar examples but no one of them appeared to be solved meanwhile.
Could anybody please help me?
Grateful thanks in advance for any opinion!
I encounter problems in obtaining a macro that inserts a "Line-column on 2 Axes" chart. The manual procedure always works and produces nice graphs but the code obtained by macro recorder always fails to work. After several attempts and variants I could say that implementing the secondary graph is the problem.
Here is the code (one of several variants which I tried):
Code:
Sub graph()
'
Charts.Add
ActiveChart.ApplyCustomType ChartType:=xlBuiltIn, TypeName:= _
"Line - Column on 2 Axes"
ActiveChart.SetSourceData Source:=Sheets("MY_SHEET").Range("A1:C238"), PlotBy:= _
xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:="MY_SHEET"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "GRAPH"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "TIME"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "VOLUME"
.Axes(xlCategory, xlSecondary).HasTitle = True '!!!HERE IS THE POINT!!!
.Axes(xlCategory, xlSecondary).AxisTitle.Characters.Text = "TIME"
.Axes(xlValue, xlSecondary).HasTitle = True
.Axes(xlValue, xlSecondary).AxisTitle.Characters.Text = "PRICE"
End With
End Sub
------------
Whenever trying to run the macro, one obtains the following message:
Code:
Run-time error '1004'
Method 'Axes' of object '_Chart' failed
Code:
.Axes(xlCategory, xlSecondary).HasTitle = True
If asking for help (in the debug assistant form) then the systems opens an empty help form and then hangs until closing that empty form.
I've googled on this matter and discovered few similar examples but no one of them appeared to be solved meanwhile.
Could anybody please help me?
Grateful thanks in advance for any opinion!