combine two ranges
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
|