combine two ranges
If you delete all of your series, then you don't have a series to assign to.
If you are going to do that, you need to add a series. Easier would be to
keep the first series since you are assigning a new range to it.
Do While pieChart.SeriesCollection.Count 1
pieChart.SeriesCollection(1).Delete
Loop
--
Regards,
Tom Ogilvy
"rtos" wrote in message
om...
I am trying following code that combines two ranges and sets the
resulting range to values and XValues in a sereis. The part I am
having trouble is
With pieChart.SeriesCollection.NewSeries
.Name = "Portfolio Allocation"
.values = stockValues
.XValues = names
End With
Its complaining about setting .values to stockValues, Whats wrong
here?
Private Sub RefreshAllocationChart()
Dim pieChart As Chart
Set pieChart = Worksheets("Main").ChartObjects(1).Chart
Do While pieChart.SeriesCollection.Count < 0
pieChart.SeriesCollection(1).Delete
Loop
Dim names As Range
Dim values As Range
Set names = Range(Range("StockSymbols"), Range("Cash"))
Set stockValues = Range(Range("StockValues"), Range("CashValue"))
With pieChart.SeriesCollection.NewSeries
.Name = "Portfolio Allocation"
.values = stockValues
.XValues = names
End With
End Sub
|