I'm getting a Runtime Error of an invalid parameter for this line of
ActiveChart.SeriesCollection(2).Select
That line of code is in this sub
Private Sub graph(graphType)
' graphCPU Macro
' Macro recorded 12/27/2002 by nmartinez
Dim SrcRange As Range
Sheets("data").Select
rowsPivotTable = Application.CountA(Sheets("data").Range("a1:a65000"))
columnsPivotTable = Application.CountA(Sheets("data").Range("a1:z1"))
Dim YAxisTitle As String
Dim chartTitleString As String
Range("A1").Select
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
"data!R1C1:R" & rowsPivotTable & "C" & columnsPivotTable).CreatePivotTable TableDestination:="", TableName:= _
"PivotTable8"
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Name = graphType
ActiveSheet.Cells(3, 1).Select
ActiveSheet.PivotTables("PivotTable8").SmallGrid = False
With ActiveSheet.PivotTables("PivotTable8").PivotFields("Year")
.Orientation = xlRowField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable8").PivotFields("TIMESTAMP")
.Orientation = xlRowField
.Position = 2
End With
With ActiveSheet.PivotTables("PivotTable8").PivotFields("NODE_ALIAS")
.Orientation = xlColumnField
.Position = 1
End With
If graphType = "CPU" Then
With ActiveSheet.PivotTables("PivotTable8").PivotFields("CPU_UTIL")
.Orientation = xlDataField
.Position = 1
.Function = xlAverage
End With
ElseIf graphType = "Memory" Then
With ActiveSheet.PivotTables("PivotTable8").PivotFields("MEM_UTIL")
.Orientation = xlDataField
.Position = 1
.Function = xlAverage
End With
ElseIf graphType = "disk_IO" Then
With ActiveSheet.PivotTables("PivotTable8").PivotFields("DISK_IO")
.Orientation = xlDataField
.Position = 1
.Function = xlAverage
End With
Else
With ActiveSheet.PivotTables("PivotTable8").PivotFields("SCANS")
.Orientation = xlDataField
.Position = 1
.Function = xlAverage
End With
End If
' With ActiveSheet.PivotTables("PivotTable8").PivotFields("MEM_UTIL")
' .Orientation = xlDataField
' .Position = 1
' .Function = xlAverage
'End With
Range("A4").Select
ActiveSheet.PivotTables("PivotTable8").PivotFields("Year").Subtotals = Array( _
False, False, False, False, False, False, False, False, False, False, False, False)
With ActiveSheet.PivotTables("PivotTable8")
.ColumnGrand = False
.RowGrand = False
End With
Range("B8").Select
Application.CommandBars("PivotTable").Visible = False
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Columns("A:A").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlToLeft
Range("A7").Select
'*********************************88
'Done with the pivot table, now we have to start graphing this thing
rowsCpuTable = Application.CountA(Sheets(graphType).Range("a4:a65000"))
columnsCputable = Application.CountA(Sheets(graphType).Range("a4:ai4"))
Range("A4:a4").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Set SrcRange = Sheets(graphType).Range(Cells(4, 1), Cells(rowsCpuTable + 4, columnsCputable))
'Range("A4:d" & rowsPivotTable).Select
Application.CutCopyMode = False
Charts.Add
ActiveChart.ChartType = xlLine
ActiveChart.SetSourceData Source:=SrcRange, PlotBy _
:=xlColumns
ActiveChart.Location Where:=xlLocationAsNewSheet
If graphType = "CPU" Or graphType = "Memory" Then
YAxisTitle = "% Utilization"
chartTitleString = graphType & " Utilization"
ElseIf graphType = "disk_IO" Then
YAxisTitle = "IO Rate"
chartTitleString = graphType & " Rate"
Else
YAxisTitle = "Scans/Second"
chartTitleString = "Memory Scans"
End If
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = chartTitleString
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "TimeStamp"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = YAxisTitle
End With
With ActiveChart
.HasAxis(xlCategory, xlPrimary) = True
.HasAxis(xlValue, xlPrimary) = True
End With
With ActiveChart.Axes(xlValue)
.MinimumScale = 0
.MaximumScaleIsAuto = True
.MinorUnitIsAuto = True
.MajorUnitIsAuto = True
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
ActiveChart.Axes(xlCategory, xlPrimary).CategoryType = xlAutomatic
ActiveChart.Legend.Select
Selection.Left = 492
Selection.Width = 180
Selection.Height = 59
Selection.Top = 4
Selection.Height = 75
Selection.Left = 469
Selection.Width = 203
Selection.Height = 53
Selection.Left = 454
Selection.Width = 218
ActiveChart.Deselect
ActiveChart.PlotArea.Select
With Selection.Border
.ColorIndex = 16
.Weight = xlThin
.LineStyle = xlContinuous
End With
Selection.Interior.ColorIndex = xlNone
'placing x axis
ActiveChart.PlotArea.Select
ActiveChart.SeriesCollection(1).Delete ' Removing the timestamp
ActiveChart.SeriesCollection(1).XValues = "=cpu!R5C1:R" & rowsCpuTable + 4 & "C1"
ActiveChart.Deselect
ActiveSheet.Name = graphType & "_Graph"
ActiveSheet.TextBoxes.Add(487003.5, 0, 17429, 22006.5).Select
Selection.Name = "Text 1"
ActiveChart.Shapes("Text 1").Select
ActiveChart.Shapes("Text 1").Height = 18
ActiveChart.Shapes("Text 1").Width = 120
ActiveChart.Shapes("Text 1").Top = 1
ActiveChart.Shapes("Text 1").Left = 50
Selection.Characters.Text = "Citigroup Internal"
With Selection.Characters(Start:=1, Length:=18).Font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 12
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 5
End With
'*********Modifications to charts if Excel 2007***********************************
If Application.Version = "12.0" Then
ActiveChart.Axes(xlCategory, xlPrimary).TickLabelSpacingIsAuto = False
ActiveChart.Axes(xlCategory, xlPrimary).TickLabelSpacing = 6
With ActiveChart.Axes(xlCategory).TickLabels
.Alignment = xlCenter
.Offset = 240
.ReadingOrder = xlContext
.Orientation = xlUpward
End With
ActiveChart.Legend.Select
Selection.Top = 0
Selection.Border.Color = xlblack
Selection.Height = 45
ActiveChart.SeriesCollection(1).Select
With Selection.Border
.ColorIndex = 26
.Weight = xlThin
End With
ActiveChart.SeriesCollection(2).Select
With Selection.Border
.ColorIndex = 6
.Weight = xlThin
End With
ActiveChart.SeriesCollection(3).Select
With Selection.Border
.ColorIndex = 8
.Weight = xlThin
End With
End If
'*********End of Modifications for Excel 2007*************************************
ActiveChart.PlotArea.Select
Selection.Width = 648
ActiveChart.Deselect
'This variable controls if we are downloading this file directly from the website
Sheets("data").Range("ht1:ht1") = 1
control = Sheets("data").Range("ht1:ht1").Value
End Sub
So how do I fix the parameter?
Bookmarks