Series range construct problem

  • Thread starter Thread starter bill..
  • Start date Start date
B

bill..

Stupid problem really

I cannot properly construct a series range object for my non adjacent
series columns:


MyRows = Range("A1").End(xlDown).Rows


ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range( _
"A2:A" & MyRows & " , C2:C" & MyRows, E2:E" & MyRows),
PlotBy:=xlColumns


The above range object is the problem.

What am I doing wrong?


Thanks

Bill
 
Bill -

Try this approach.

Sub DoChart()
Dim MyRows As Long
MyRows = Sheets("Sheet1").Range("A1").End(xlDown).Rows

Dim rng1 As Range
Dim rng2 As Range
Dim rngChart As Range

Set rng1 = Sheets("Sheet1").Cells(2, 1).Resize(MyRows - 1)
Set rng2 = Sheets("Sheet1").Cells(2, 3).Resize(MyRows - 1)
Set rngChart = Union(rng1, rng2)

ActiveChart.SetSourceData Source:=rngChart, PlotBy:=xlColumns
End Sub

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______
 
Back
Top