Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run-time error `91': Object variable . . . not set
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 Whe=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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run-time error `91': Object variable . . . not set
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. "Alan" wrote: 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 Whe=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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run-time error `91': Object variable . . . not set
Joel,
Thanks. I found some cells containing blank spaces. Alan |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Run-Time error '91': Object variable of With block variable not set | Excel Programming | |||
Run time error '91' object variable-explain in plain english?? | Excel Discussion (Misc queries) | |||
Run-time Error '91' Object Variable Not Set | Excel Programming | |||
Run-time error '91': "Object variable or With block variable not set | Excel Programming | |||
"Run-time error 91: Object variable or With block not set" | Excel Programming |