T
Tommy
Hi guys,
I have a small subroutine which, when run, will select a range of
cells for me based on certain criteria given to it. Typically I am
left with a selection of data in a single column e.g. AC7:AC100.
My goal is to plot this data as a series in a chart. Currently, the
code I have for my chart is:
Set Chart1 = Worksheets("Tuning").ChartObjects(1)
Chart1.Activate
With Chart1.Chart
' Clear all previous series.
Do Until .SeriesCollection.Count = 0
.SeriesCollection(1).Delete
Loop
.Type = xlLine
.SeriesCollection(1).Values = DataSource1
.SeriesCollection(1).Name = "Tag 1"
.HasTitle = True
.ChartTitle.Text = "Chart 1 Title"
End With
As you can see, it selects the ChartObject(1) called Chart1, deletes
all previous series on the chart and then adds a single series. Here
is where I get the problem. I need that original selection of
AC7:AC100 being stored as a range named DataSource1. I have no idea
however how to store an active/current selection as a range so that
this code will work. If you believe I can do it better another way,
please suggest so. I must note that I have to use ChartObjects as I
have other code that relies on this fact.
Many regards and thanks,
Tom
I have a small subroutine which, when run, will select a range of
cells for me based on certain criteria given to it. Typically I am
left with a selection of data in a single column e.g. AC7:AC100.
My goal is to plot this data as a series in a chart. Currently, the
code I have for my chart is:
Set Chart1 = Worksheets("Tuning").ChartObjects(1)
Chart1.Activate
With Chart1.Chart
' Clear all previous series.
Do Until .SeriesCollection.Count = 0
.SeriesCollection(1).Delete
Loop
.Type = xlLine
.SeriesCollection(1).Values = DataSource1
.SeriesCollection(1).Name = "Tag 1"
.HasTitle = True
.ChartTitle.Text = "Chart 1 Title"
End With
As you can see, it selects the ChartObject(1) called Chart1, deletes
all previous series on the chart and then adds a single series. Here
is where I get the problem. I need that original selection of
AC7:AC100 being stored as a range named DataSource1. I have no idea
however how to store an active/current selection as a range so that
this code will work. If you believe I can do it better another way,
please suggest so. I must note that I have to use ChartObjects as I
have other code that relies on this fact.
Many regards and thanks,
Tom