Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Help: runtime error "method seriescollection object_chart failed"


Hello,

I have a draw chart sub which generates a runtime error "method
seriescollection object_chart failed" from time to time. It doesn't
happen all the time, probaly around 15% of the time. Below is the full
code. I'm running out of ideas now in terms of how to fix the problem.
Please help!!

Thanks a lot
---------------------------------------------------------------------------------------------------
Sub drawChart(nYears As Integer)

Dim TempChartObjA As ChartObject
Dim TempChartObjB As ChartObject
Dim TempChartObjC As ChartObject
Dim TempChartObjD As ChartObject
Dim chartCount As Integer
Dim i As Integer
Dim TempSeriesCollection As SeriesCollection

Call drawCheckBox(nYears)

chartCount = Worksheets("DashBoard").ChartObjects.Count
If chartCount 0 Then
For i = 1 To chartCount
Worksheets("DashBoard").ChartObjects(1).Delete
Next i
End If

'reset the average line check boxes
Worksheets("DashBoard").cb_DailyAverage.Visible = True
Worksheets("DashBoard").cb_DailyAverage.Value = False
Worksheets("DashBoard").cb_DailyAveragePercent.Vis ible = False
Worksheets("DashBoard").cb_DailyAveragePercent.Val ue = False

Set TempChartObjA = Worksheets("DashBoard").ChartObjects.Add(0, 0, 700,
300)
Set TempChartObjC = Worksheets("DashBoard").ChartObjects.Add(0, 0, 700,
300)
Set TempChartObjB = Worksheets("DashBoard").ChartObjects.Add(0, 0, 700,
300)
Set TempChartObjD = Worksheets("DashBoard").ChartObjects.Add(0, 0, 700,
300)

TempChartObjA.Name = "chartGDM"
TempChartObjC.Name = "chartGDMPercent"
TempChartObjB.Name = "chartIFERC"
TempChartObjD.Name = "chartIFERCPercent"

TempChartObjA.Activate
ActiveChart.chartType = xlLineMarkers
TempChartObjC.Activate
ActiveChart.chartType = xlLineMarkers

If ifercHasCharts Then
Worksheets("DashBoard").cb_MonthlyAverage.Visible = False
Worksheets("DashBoard").cb_MonthlyAverage.Value = False
Worksheets("DashBoard").cb_MonthlyAveragePercent.V isible = False
Worksheets("DashBoard").cb_MonthlyAveragePercent.V alue = False

TempChartObjB.Activate
ActiveChart.chartType = xlLineMarkers
TempChartObjD.Activate
ActiveChart.chartType = xlLineMarkers
End If


'Add new series data to the series collection to charts
For i = 0 To nYears
' chartGDM
TempChartObjA.Activate
'On Error Resume Next
'Worksheets("DataMap").ShowAllData
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(i + 1).XValues = "=DataMap!dateAxisAll"
ActiveChart.SeriesCollection(i + 1).Name = "Year " & Year(Now()) - i
ActiveChart.SeriesCollection(i + 1).Values = "=DataMap!DataYear" &
Year(Now()) - i


ActiveChart.SeriesCollection(i + 1).Select
With Selection.Border
..Weight = xlThin
..LineStyle = xlAutomatic
End With
With Selection
..MarkerBackgroundColorIndex = xlAutomatic
..MarkerForegroundColorIndex = xlAutomatic
..MarkerStyle = xlSquare
..Smooth = False
..MarkerSize = 3
..Shadow = False
End With

' chartGDMPercent
TempChartObjC.Activate
'On Error Resume Next
'Worksheets("DataMap").ShowAllData
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(i + 1).XValues = "=DataMap!dateAxisAll"
ActiveChart.SeriesCollection(i + 1).Name = "Year " & Year(Now()) - i
ActiveChart.SeriesCollection(i + 1).Values = "=DataMap!DataYearPercent"
& Year(Now()) - i

ActiveChart.SeriesCollection(i + 1).Select
With Selection.Border
..Weight = xlThin
..LineStyle = xlAutomatic
End With
With Selection
..MarkerBackgroundColorIndex = xlAutomatic
..MarkerForegroundColorIndex = xlAutomatic
..MarkerStyle = xlSquare
..Smooth = False
..MarkerSize = 3
..Shadow = False
End With

If ifercHasCharts Then
'chartIFERC
TempChartObjB.Activate
'On Error Resume Next
'Worksheets("DataMap").ShowAllData
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(i + 1).XValues =
"=DataMap!ifercChartMonthAxis"
ActiveChart.SeriesCollection(i + 1).Name = "Year " & Year(Now()) - i
ActiveChart.SeriesCollection(i + 1).Values = "=DataMap!IFERCDataYear" &
Year(Now()) - i
ActiveChart.SeriesCollection

'chartIFERCPercent
TempChartObjD.Activate
'On Error Resume Next
'Worksheets("DataMap").ShowAllData
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(i + 1).XValues =
"=DataMap!ifercChartMonthAxis"
ActiveChart.SeriesCollection(i + 1).Name = "Year " & Year(Now()) - i
ActiveChart.SeriesCollection(i + 1).Values =
"=DataMap!IFERCDataYearPercent" & Year(Now()) - i
ActiveChart.SeriesCollection
End If
Next i

TempChartObjA.Activate

With ActiveChart
..HasTitle = True
..ChartTitle.Text = "Gas Daily Average Spread: Receiving " &
Worksheets("SymbolMap").Range _
("longLoc") & "- Delivery " &
Worksheets("SymbolMap").Range("shortLoc")
End With

ActiveChart.Axes(xlValue).TickLabels.NumberFormat =
"$#,##0.0_);[Red]($#,##0.0)"

ActiveChart.Axes(xlCategory).Select
With Selection.Border
..ColorIndex = 57
..Weight = xlMedium
..LineStyle = xlContinuous
End With
With Selection
..TickLabelSpacing = 20
..MajorTickMark = xlNone
..MinorTickMark = xlNone
..TickLabelPosition = xlLow
End With
ActiveChart.Axes(xlValue).MajorGridlines.Select
With Selection.Border
..ColorIndex = 57
..Weight = xlHairline
..LineStyle = xlGray50
End With

ActiveChart.PlotArea.Select
With ActiveChart
..Axes(xlCategory, xlPrimary).HasTitle = True
..Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Date"
..Axes(xlValue, xlPrimary).HasTitle = True
..Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Spread"
End With
With ActiveChart.Axes(xlCategory)
..HasMajorGridlines = True
..HasMinorGridlines = False
End With
With ActiveChart.Axes(xlValue)
..HasMajorGridlines = True
..HasMinorGridlines = False
End With
ActiveChart.Axes(xlCategory).MajorGridlines.Select
With Selection.Border
..ColorIndex = 57
..Weight = xlHairline
..LineStyle = xlGray50
End With
With ActiveChart.Axes(xlCategory)
..CrossesAt = 1
..TickLabelSpacing = 20
..TickMarkSpacing = 20
..AxisBetweenCategories = True
..ReversePlotOrder = False
End With

'################################################# ###
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 230
Default runtime error "method seriescollection object_chart failed"

See if this post helps you, you have too much code for me to go through at
this hour, but this thread may provide a clue possibly.

http://groups-beta.google.com/group/...d0e874e0d2baa8


"huangx06" wrote in
message ...

Hello,

I have a draw chart sub which generates a runtime error "method
seriescollection object_chart failed" from time to time. It doesn't
happen all the time, probaly around 15% of the time. Below is the full
code. I'm running out of ideas now in terms of how to fix the problem.
Please help!!

Thanks a lot
---------------------------------------------------------------------------------------------------
Sub drawChart(nYears As Integer)

Dim TempChartObjA As ChartObject
Dim TempChartObjB As ChartObject
Dim TempChartObjC As ChartObject
Dim TempChartObjD As ChartObject
Dim chartCount As Integer
Dim i As Integer
Dim TempSeriesCollection As SeriesCollection

Call drawCheckBox(nYears)

chartCount = Worksheets("DashBoard").ChartObjects.Count
If chartCount 0 Then
For i = 1 To chartCount
Worksheets("DashBoard").ChartObjects(1).Delete
Next i
End If

'reset the average line check boxes
Worksheets("DashBoard").cb_DailyAverage.Visible = True
Worksheets("DashBoard").cb_DailyAverage.Value = False
Worksheets("DashBoard").cb_DailyAveragePercent.Vis ible = False
Worksheets("DashBoard").cb_DailyAveragePercent.Val ue = False

Set TempChartObjA = Worksheets("DashBoard").ChartObjects.Add(0, 0, 700,
300)
Set TempChartObjC = Worksheets("DashBoard").ChartObjects.Add(0, 0, 700,
300)
Set TempChartObjB = Worksheets("DashBoard").ChartObjects.Add(0, 0, 700,
300)
Set TempChartObjD = Worksheets("DashBoard").ChartObjects.Add(0, 0, 700,
300)

TempChartObjA.Name = "chartGDM"
TempChartObjC.Name = "chartGDMPercent"
TempChartObjB.Name = "chartIFERC"
TempChartObjD.Name = "chartIFERCPercent"

TempChartObjA.Activate
ActiveChart.chartType = xlLineMarkers
TempChartObjC.Activate
ActiveChart.chartType = xlLineMarkers

If ifercHasCharts Then
Worksheets("DashBoard").cb_MonthlyAverage.Visible = False
Worksheets("DashBoard").cb_MonthlyAverage.Value = False
Worksheets("DashBoard").cb_MonthlyAveragePercent.V isible = False
Worksheets("DashBoard").cb_MonthlyAveragePercent.V alue = False

TempChartObjB.Activate
ActiveChart.chartType = xlLineMarkers
TempChartObjD.Activate
ActiveChart.chartType = xlLineMarkers
End If


'Add new series data to the series collection to charts
For i = 0 To nYears
' chartGDM
TempChartObjA.Activate
'On Error Resume Next
'Worksheets("DataMap").ShowAllData
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(i + 1).XValues = "=DataMap!dateAxisAll"
ActiveChart.SeriesCollection(i + 1).Name = "Year " & Year(Now()) - i
ActiveChart.SeriesCollection(i + 1).Values = "=DataMap!DataYear" &
Year(Now()) - i


ActiveChart.SeriesCollection(i + 1).Select
With Selection.Border
Weight = xlThin
LineStyle = xlAutomatic
End With
With Selection
MarkerBackgroundColorIndex = xlAutomatic
MarkerForegroundColorIndex = xlAutomatic
MarkerStyle = xlSquare
Smooth = False
MarkerSize = 3
Shadow = False
End With

' chartGDMPercent
TempChartObjC.Activate
'On Error Resume Next
'Worksheets("DataMap").ShowAllData
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(i + 1).XValues = "=DataMap!dateAxisAll"
ActiveChart.SeriesCollection(i + 1).Name = "Year " & Year(Now()) - i
ActiveChart.SeriesCollection(i + 1).Values = "=DataMap!DataYearPercent"
& Year(Now()) - i

ActiveChart.SeriesCollection(i + 1).Select
With Selection.Border
Weight = xlThin
LineStyle = xlAutomatic
End With
With Selection
MarkerBackgroundColorIndex = xlAutomatic
MarkerForegroundColorIndex = xlAutomatic
MarkerStyle = xlSquare
Smooth = False
MarkerSize = 3
Shadow = False
End With

If ifercHasCharts Then
'chartIFERC
TempChartObjB.Activate
'On Error Resume Next
'Worksheets("DataMap").ShowAllData
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(i + 1).XValues =
"=DataMap!ifercChartMonthAxis"
ActiveChart.SeriesCollection(i + 1).Name = "Year " & Year(Now()) - i
ActiveChart.SeriesCollection(i + 1).Values = "=DataMap!IFERCDataYear" &
Year(Now()) - i
ActiveChart.SeriesCollection

'chartIFERCPercent
TempChartObjD.Activate
'On Error Resume Next
'Worksheets("DataMap").ShowAllData
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(i + 1).XValues =
"=DataMap!ifercChartMonthAxis"
ActiveChart.SeriesCollection(i + 1).Name = "Year " & Year(Now()) - i
ActiveChart.SeriesCollection(i + 1).Values =
"=DataMap!IFERCDataYearPercent" & Year(Now()) - i
ActiveChart.SeriesCollection
End If
Next i

TempChartObjA.Activate

With ActiveChart
HasTitle = True
ChartTitle.Text = "Gas Daily Average Spread: Receiving " &
Worksheets("SymbolMap").Range _
("longLoc") & "- Delivery " &
Worksheets("SymbolMap").Range("shortLoc")
End With

ActiveChart.Axes(xlValue).TickLabels.NumberFormat =
"$#,##0.0_);[Red]($#,##0.0)"

ActiveChart.Axes(xlCategory).Select
With Selection.Border
ColorIndex = 57
Weight = xlMedium
LineStyle = xlContinuous
End With
With Selection
TickLabelSpacing = 20
MajorTickMark = xlNone
MinorTickMark = xlNone
TickLabelPosition = xlLow
End With
ActiveChart.Axes(xlValue).MajorGridlines.Select
With Selection.Border
ColorIndex = 57
Weight = xlHairline
LineStyle = xlGray50
End With

ActiveChart.PlotArea.Select
With ActiveChart
Axes(xlCategory, xlPrimary).HasTitle = True
Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Date"
Axes(xlValue, xlPrimary).HasTitle = True
Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Spread"
End With
With ActiveChart.Axes(xlCategory)
HasMajorGridlines = True
HasMinorGridlines = False
End With
With ActiveChart.Axes(xlValue)
HasMajorGridlines = True
HasMinorGridlines = False
End With
ActiveChart.Axes(xlCategory).MajorGridlines.Select
With Selection.Border
ColorIndex = 57
Weight = xlHairline
LineStyle = xlGray50
End With
With ActiveChart.Axes(xlCategory)
CrossesAt = 1
TickLabelSpacing = 20
TickMarkSpacing = 20
AxisBetweenCategories = True
ReversePlotOrder = False
End With

'################################################# ###



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help: runtime error - Method seriescollection object_chart failed huangx06 Charts and Charting in Excel 3 July 9th 05 12:27 AM
"GoalSeek method of Range object failed" error message Fixit_Steve Excel Programming 0 January 13th 05 07:29 PM
VBA error 1004 "Select method of Range class failed" Matt J Excel Programming 6 July 3rd 04 10:05 PM
Error 1004, "select method of range class failed" paritoshmehta[_11_] Excel Programming 3 May 6th 04 10:09 PM
Runtime Error "1004" Select Method of Range Class Failed Stephen[_7_] Excel Programming 4 April 10th 04 06:28 AM


All times are GMT +1. The time now is 01:25 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"