![]() |
Error when create chartobject on line ".HasTitle = True"
Hi,
I gett runtime 1004 at line "HasTitle = True" The peculiar thing is that yesterday it worked ok. I saved it, slept, and now I get the error. I have tested to put the Has title ocde in the end of the sub, after seriescollections etc, but with same results. Any ideas, anybody? /Kind regards tskogstrom Sub CreateChartCF() Dim cht As Chart Dim chtTitle As String chtTitle = "CashFlow & PayBack" On Error Resume Next '(if no chartobject) Sheet2.ChartObjects("R_CF").Delete On Error GoTo 0 If Sheet1.Range("Years").Value 1 Then With Sheet2.ChartObjects.Add(Range("RAPP_BASE_CHT_CF"). Left, _ Range("RAPP_BASE_CHT_CF").Top, 468, 260) .Name = "R_CF" End With Set cht = Sheet2.ChartObjects("R_CF").Chart With cht .ChartType = xlColumnClustered .SetSourceData Sheet10.Range("CHT_CFSOURCE_" & Sheet2.Range("RAPP_TILLF").Value), _ PlotBy:=xlRows .HasTitle = True .Axes(xlCategory, xlPrimary).HasTitle = False .Axes(xlValue, xlPrimary).HasTitle = False .ChartTitle.Characters.Text = chtTitle End With With cht.SeriesCollection(1) .Fill.OneColorGradient Style:=msoGradientVertical, Variant:=4, _ Degree:=0.25 .Fill.Visible = True .Fill.ForeColor.SchemeColor = 47 End With With cht.SeriesCollection(2) .Fill.OneColorGradient Style:=msoGradientVertical, Variant:=4, _ Degree:=0.25 .Fill.Visible = True .Fill.ForeColor.SchemeColor = 45 End With ....etc etc |
Error when create chartobject on line ".HasTitle = True"
It seems that if the source is hidden rows or columns, I get the error
!! Is this really correct? Is there any workarounds in code, or do I need to create a new sheet with linked sourceranges? That would be some trouble to me ... /Regards tskogstrom tskogstrom skrev: Hi, I gett runtime 1004 at line "HasTitle = True" The peculiar thing is that yesterday it worked ok. I saved it, slept, and now I get the error. I have tested to put the Has title ocde in the end of the sub, after seriescollections etc, but with same results. Any ideas, anybody? /Kind regards tskogstrom Sub CreateChartCF() Dim cht As Chart Dim chtTitle As String chtTitle = "CashFlow & PayBack" On Error Resume Next '(if no chartobject) Sheet2.ChartObjects("R_CF").Delete On Error GoTo 0 If Sheet1.Range("Years").Value 1 Then With Sheet2.ChartObjects.Add(Range("RAPP_BASE_CHT_CF"). Left, _ Range("RAPP_BASE_CHT_CF").Top, 468, 260) .Name = "R_CF" End With Set cht = Sheet2.ChartObjects("R_CF").Chart With cht .ChartType = xlColumnClustered .SetSourceData Sheet10.Range("CHT_CFSOURCE_" & Sheet2.Range("RAPP_TILLF").Value), _ PlotBy:=xlRows .HasTitle = True .Axes(xlCategory, xlPrimary).HasTitle = False .Axes(xlValue, xlPrimary).HasTitle = False .ChartTitle.Characters.Text = chtTitle End With With cht.SeriesCollection(1) .Fill.OneColorGradient Style:=msoGradientVertical, Variant:=4, _ Degree:=0.25 .Fill.Visible = True .Fill.ForeColor.SchemeColor = 47 End With With cht.SeriesCollection(2) .Fill.OneColorGradient Style:=msoGradientVertical, Variant:=4, _ Degree:=0.25 .Fill.Visible = True .Fill.ForeColor.SchemeColor = 45 End With ...etc etc |
Error when create chartobject on line ".HasTitle = True"
Hi,
If your chart contains no data then either manually or with code you will not be able to set the chart title. If you need a chart title even when no data is present you could add a dummy series. Cheers Andy tskogstrom wrote: It seems that if the source is hidden rows or columns, I get the error !! Is this really correct? Is there any workarounds in code, or do I need to create a new sheet with linked sourceranges? That would be some trouble to me ... /Regards tskogstrom tskogstrom skrev: Hi, I gett runtime 1004 at line "HasTitle = True" The peculiar thing is that yesterday it worked ok. I saved it, slept, and now I get the error. I have tested to put the Has title ocde in the end of the sub, after seriescollections etc, but with same results. Any ideas, anybody? /Kind regards tskogstrom Sub CreateChartCF() Dim cht As Chart Dim chtTitle As String chtTitle = "CashFlow & PayBack" On Error Resume Next '(if no chartobject) Sheet2.ChartObjects("R_CF").Delete On Error GoTo 0 If Sheet1.Range("Years").Value 1 Then With Sheet2.ChartObjects.Add(Range("RAPP_BASE_CHT_CF"). Left, _ Range("RAPP_BASE_CHT_CF").Top, 468, 260) .Name = "R_CF" End With Set cht = Sheet2.ChartObjects("R_CF").Chart With cht .ChartType = xlColumnClustered .SetSourceData Sheet10.Range("CHT_CFSOURCE_" & Sheet2.Range("RAPP_TILLF").Value), _ PlotBy:=xlRows .HasTitle = True .Axes(xlCategory, xlPrimary).HasTitle = False .Axes(xlValue, xlPrimary).HasTitle = False .ChartTitle.Characters.Text = chtTitle End With With cht.SeriesCollection(1) .Fill.OneColorGradient Style:=msoGradientVertical, Variant:=4, _ Degree:=0.25 .Fill.Visible = True .Fill.ForeColor.SchemeColor = 47 End With With cht.SeriesCollection(2) .Fill.OneColorGradient Style:=msoGradientVertical, Variant:=4, _ Degree:=0.25 .Fill.Visible = True .Fill.ForeColor.SchemeColor = 45 End With ...etc etc |
All times are GMT +1. The time now is 05:39 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com