R
Roland
I want to create a chart with 1 serie which has data from 4 discontiguous
cells.
I defined 'b=6' but in practice it has a variable value, also counter has
variable values.
I tried two methods:
1/ with the union method to make a multirange selection
2/ by combining the cell addresses to a string.
None of these works. How do I solve this?
thanx in advance
Sub Macro1()
Charts.Add
With ActiveChart
.ChartType = xlColumnClustered
.SetSourceData Source:=Sheets("Summery").Range("A21:I40"), PlotBy:=xlRows
.SeriesCollection.NewSeries
.SeriesCollection(1).XValues = "={""x1"",""x2"",""x3"",""x4""}"
Set temprange = Range(Cells(2, b))
For counter = 4 To 8 Step 2
Set temprange = Union(temprange, Range(Cells(counter, b)))
Next
.SeriesCollection(1).Values = temprange
'tempstring = Cells(2, b).Address
'For counter = 4 To 8 Step 2
' tempstring = tempstring & "," & Cells(counter, b).Address
'Next
'.SeriesCollection(1).Values = range(tempstring)
.SeriesCollection(1).Name = "=""test"""
.Location Where:=xlLocationAsObject, Name:="Summery"
End With
End Sub
cells.
I defined 'b=6' but in practice it has a variable value, also counter has
variable values.
I tried two methods:
1/ with the union method to make a multirange selection
2/ by combining the cell addresses to a string.
None of these works. How do I solve this?
thanx in advance
Sub Macro1()
Charts.Add
With ActiveChart
.ChartType = xlColumnClustered
.SetSourceData Source:=Sheets("Summery").Range("A21:I40"), PlotBy:=xlRows
.SeriesCollection.NewSeries
.SeriesCollection(1).XValues = "={""x1"",""x2"",""x3"",""x4""}"
Set temprange = Range(Cells(2, b))
For counter = 4 To 8 Step 2
Set temprange = Union(temprange, Range(Cells(counter, b)))
Next
.SeriesCollection(1).Values = temprange
'tempstring = Cells(2, b).Address
'For counter = 4 To 8 Step 2
' tempstring = tempstring & "," & Cells(counter, b).Address
'Next
'.SeriesCollection(1).Values = range(tempstring)
.SeriesCollection(1).Name = "=""test"""
.Location Where:=xlLocationAsObject, Name:="Summery"
End With
End Sub