Run-time error `91': Object variable . . . not set

A

Alan

Any idea what this error means? It occurs at the following line in my
code in subroutine "CreateWPMchart""

ActiveChart.SeriesCollection(3).Select

I am running the subroutine FixAndCreateCharts() on a CSV file. The
most relevant code may be found below.

Thanks, Alan

Sub FixAndCreateCharts()
ActiveCell.Columns("A:G").EntireColumn.Select
Selection.ColumnWidth = 17.71
ActiveCell.Rows("1:1").EntireRow.Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Font.Bold = True
FormatPageFileByte

Call CreateWPMchart("A:A,C:C,E:E,G:G", "CPU Utilization", "% Processor
Time")

End Sub

Sub FormatPageFileByte()
ActiveCell.Range("B:B,D:D,F:F").Select
Selection.NumberFormat = "0.00E+00"
End Sub

Sub CreateWPMchart(ColumnRange As String, ChartName As String,
yAxisTitle As String)

Worksheets("FIXED_PerfWiz - 5 second Interv").Activate

Charts.Add

ActiveChart.ChartType = xlLineMarkers

MsgBox ("In CreateWPMchart - prior to chart creation, Column Range: "
& ColumnRange)

ActiveChart.SetSourceData Source:=Sheets("FIXED_PerfWiz - 5 second
interv"). _
Range(ColumnRange), PlotBy:=xlColumns

ActiveChart.Location Where:=xlLocationAsNewSheet, Name:=ChartName
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = ChartName
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = _
"Time (5 sec. intervals)"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text =
yAxisTitle
End With
With ActiveChart.Axes(xlCategory)
.HasMajorGridlines = False
.HasMinorGridlines = False
End With
With ActiveChart.Axes(xlValue)
.HasMajorGridlines = True
.HasMinorGridlines = False
End With
ActiveChart.HasDataTable = False

ActiveChart.ChartArea.Select
ActiveChart.SeriesCollection(3).Select
With Selection.Border
.ColorIndex = 10
.Weight = xlThin
.LineStyle = xlContinuous
End With
With Selection
.MarkerBackgroundColorIndex = 10
.MarkerForegroundColorIndex = 10
.MarkerStyle = xlTriangle
.Smooth = False
.MarkerSize = 5
.Shadow = False
End With

ActiveChart.ChartArea.Select
ActiveChart.SeriesCollection(2).Select
With Selection.Border
.ColorIndex = 9
.Weight = xlThin
.LineStyle = xlContinuous
End With
With Selection
.MarkerBackgroundColorIndex = 9
.MarkerForegroundColorIndex = 9
.MarkerStyle = xlSquare
.Smooth = False
.MarkerSize = 5
.Shadow = False
End With

End Sub
 
J

Joel

The code ran without errors in excel 2003. I simply put sequential number in
the worksheet "FIXED_PerfWiz - 5 second Interv".

Row 1 contained 1, 2, 3, 4, 5 ... 12
Row 2 contained 2, 3, 4, 5, 6 ... 13
Row 3 contained 3, 4, 5, 6, 7 ... 14

I continued like this up to row 19.


I think the problem may be that you data has problems. also make sure you
delete the chart sheet before you run the code so you don't get a duplicate
sheet name.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top