View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.charting
Robert Baer Robert Baer is offline
external usenet poster
 
Posts: 93
Default Cannot change Series references

Tushar Mehta wrote:
The one time that that can happen is if all the cells in the specified range
are empty.

Most definitely not empty; B43..BQ79 are completely populated.
Courtesy of your suggestions, i now can make multiple charts spaced
the way i want, and have the titles what i want.
Had to make a minor change, tho.
But still cannot change the series references.
What i have so far:

Sub Macro7()
'
' Macro7: Chart titles and positions change OK; cannot change series

TitleName = "Stripper Well Survey - "
Windows("StripperWellsMod.xls").Activate
Sheets("Charts").Select
Range("A1").Select
SheetRow = 1
ChartNum = 1
CTitle = TitleName + Sheets("#of wells").Cells(43 + ChartNum, 2).Value
' With Worksheets("Charts").ChartObjects(1).Chart <---does not work here
' so be eXplicit..
With Worksheets("Charts").ChartObjects("Chart 1").Chart
.HasTitle = True
.ChartTitle.Text = CTitle
.ChartArea.Copy
End With
For ChartNum = 2 To 5
CTitle = TitleName + Sheets("#of wells").Cells(43 + ChartNum, 2).Value
RowLoc = LTrim(Str$(43 + ChartNum))
Series_1 = "='#of wells'!$C$" + RowLoc + ":$BQ$" + RowLoc
Series_2 = "=Production!$C$" + RowLoc + ":$BQ$" + RowLoc
With Worksheets("Charts")
.Paste
With .ChartObjects(.ChartObjects.Count)
.Top = Worksheets("Charts").Cells(SheetRow + 21, 1).Top
.Left = Worksheets("Charts").Cells(SheetRow + 21, 1).Left
' Following does not work; "Unable to set the Values property of the
Series class"
' .Chart.SeriesCollection(1).Values = Series_1
With .Chart
.HasTitle = True
.ChartTitle.Text = CTitle
.ChartArea.Copy
End With
End With
End With
With ActiveSheet.ChartObjects
.Item(.Count).Chart.SeriesCollection(1).Values = Series_1
End With
SheetRow = SheetRow + 21
Next ChartNum
' Following does not work; "Unable to set the Values property of the
Series class"
' With ActiveSheet.ChartObjects
' .Item(.Count).Chart.SeriesCollection(1).Values = "=charts!$L$2:$N$2"
' End With

' deliberate error to force allowance of debug
ActiveChart.ChartTitle = "foo"
End Sub