J
JacksonRJones
Hello. I am having trouble with charting from vba. I used the macro
recorder to generate code to creat charts, and am only trying to create a
single series. Sometimes additional series will show up on the chart, either
blank ones, or sometimes series with only yvalues. Any help would be greatly
appreciated. Here is the code I am using for the charts:
(i is an integer)
Dim xrng As Range
Dim yrng As Range
Set xrng = Worksheets("sheet1").Range("A5:A" & i - 1)
Set yrng = Worksheets("sheet1").Range("B5:B" & i - 1)
Charts.Add
ActiveChart.ChartType = xlXYScatterSmoothNoMarkers
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).XValues = xrng
ActiveChart.SeriesCollection(1).Values = yrng
ActiveChart.Location Where:=xlLocationAsNewSheet
With ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
recorder to generate code to creat charts, and am only trying to create a
single series. Sometimes additional series will show up on the chart, either
blank ones, or sometimes series with only yvalues. Any help would be greatly
appreciated. Here is the code I am using for the charts:
(i is an integer)
Dim xrng As Range
Dim yrng As Range
Set xrng = Worksheets("sheet1").Range("A5:A" & i - 1)
Set yrng = Worksheets("sheet1").Range("B5:B" & i - 1)
Charts.Add
ActiveChart.ChartType = xlXYScatterSmoothNoMarkers
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).XValues = xrng
ActiveChart.SeriesCollection(1).Values = yrng
ActiveChart.Location Where:=xlLocationAsNewSheet
With ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With