C
carloshernandezy
Hello,
I am trying to create a dynamic chart using code in a diferent workbook
from the code one and it´s imposible for me. I can create one dynamic
chart in the same workbook of the code but when I try this code to
create the grph in a different workbook the problems appears.
Thank you in advance.
The data is coloumn "C".
The code that generate error is the one with >>>>>
___The code is this one ____
Sub Grafico()
'
ActiveWorkbook.Names.Add Name:="RngC", RefersToR1C1:= _
"=OFFSET(Hoja1!R2C3,0,0,COUNTA(Hoja1!C3)-1)"
Sheets(1).Name = "TOC"
Charts.Add
ActiveChart.ChartType = xlXYScatterSmoothNoMarkers
ActiveChart.SetSourceData Source:=Sheets("TOC").Range("C2:C3065"),
PlotBy:= _
xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:="TOC"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "TOC en "
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "ppb"
End With
With ActiveChart.Axes(xlCategory)
.HasMajorGridlines = False
.HasMinorGridlines = False
End With
With ActiveChart.Axes(xlValue)
.HasMajorGridlines = False
.HasMinorGridlines = False
End With
ActiveChart.HasLegend = False
ActiveChart.ApplyDataLabels Type:=xlDataLabelsShowNone,
LegendKey:=False
ActiveChart.PlotArea.Select
With Selection.Border
.ColorIndex = 16
.Weight = xlThin
.LineStyle = xlContinuous
End With
With Selection.Interior
.ColorIndex = 2
.PatternColorIndex = 1
.Pattern = xlSolid
End With
End Sub
I am trying to create a dynamic chart using code in a diferent workbook
from the code one and it´s imposible for me. I can create one dynamic
chart in the same workbook of the code but when I try this code to
create the grph in a different workbook the problems appears.
Thank you in advance.
The data is coloumn "C".
The code that generate error is the one with >>>>>
___The code is this one ____
Sub Grafico()
'
ActiveWorkbook.Names.Add Name:="RngC", RefersToR1C1:= _
"=OFFSET(Hoja1!R2C3,0,0,COUNTA(Hoja1!C3)-1)"
Sheets(1).Name = "TOC"
Charts.Add
ActiveChart.ChartType = xlXYScatterSmoothNoMarkers
ActiveChart.SetSourceData Source:=Sheets("TOC").Range("C2:C3065"),
PlotBy:= _
xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:="TOC"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "TOC en "
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "ppb"
End With
With ActiveChart.Axes(xlCategory)
.HasMajorGridlines = False
.HasMinorGridlines = False
End With
With ActiveChart.Axes(xlValue)
.HasMajorGridlines = False
.HasMinorGridlines = False
End With
ActiveChart.HasLegend = False
ActiveChart.ApplyDataLabels Type:=xlDataLabelsShowNone,
LegendKey:=False
ActiveChart.PlotArea.Select
With Selection.Border
.ColorIndex = 16
.Weight = xlThin
.LineStyle = xlContinuous
End With
With Selection.Interior
.ColorIndex = 2
.PatternColorIndex = 1
.Pattern = xlSolid
End With
End Sub