G
Guest
Hi
I have a serious problem with a chart that I made using VBA.
I get the error: Runtime error 1004:
"Unable to set the values property of the series class"
and sometimes the same error but just for the named property of the series.
The chart is a standard lines chart.
I hope somebody can help me
Below is the section of code that is flagged:
Sub ChartOptions()
' this sets up the QC Graph for the main lab with Chart title,
' axis title and scale of Y-axis according to each parameter
Sheets("Calcs").Select
ActiveCell = Cells(3, 2)
ActiveCell.Offset(1, 0).Select
ActiveCell.FormulaR1C1 = "=Ave+1*(STDEV)" ' UWL
ActiveCell.Offset(1, 0).Select
ActiveCell.FormulaR1C1 = "=Ave-1*(STDEV)" 'LWL
ActiveCell.Offset(1, 0).Select
ActiveCell.FormulaR1C1 = "=Ave+3*(STDEV)" 'UCL
ActiveCell.Offset(1, 0).Select
ActiveCell.FormulaR1C1 = "=Ave-3*(STDEV)" 'LCL
Range("B3:B7").Select
Selection.Copy
Range("C3:AZ7").Select
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
a = MsgBox("Limits data created. Click Ok to view Graph", vbOKOnly,
"Limits Data")
If a = vbOK Then
Sheets("QC Graph").Select
With Charts("QC Graph") 'this sets up the chart title, axis
title and legend
.HasTitle = True
.ChartTitle.Text = "QC Graph for:" & " " & QCType & " "
& "at the" & " " & QCSection
.SeriesCollection(1).Name = QCType
**** .SeriesCollection(1).Values = QCData *****
End With
With Charts("QC Graph").Axes(xlValue)
.HasTitle = True
.AxisTitle.Text = QCType
End With
End If
'this sets up the various QCtypes' Y-axis scales
If QCSection = "Clean Lab" Then
Select Case SectionNumber
Case 1 To 4 'Cl,SO4,Fe,Cu
Sheets("QC Graph").Select
With Charts("QC Graph").Axes(xlValue)
.MinimumScale = 5
.MaximumScale = 15
.MinorUnitIsAuto = True
.MajorUnitIsAuto = True
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
End Select
ElseIf QCSection = "Boiler Bench" Then
Select Case SectionNumber
Case 1 'Na
Sheets("QC Graph").Select
With Charts("QC Graph").Axes(xlValue)
.MinimumScale = 5
.MaximumScale = 15
.MinorUnitIsAuto = True
.MajorUnitIsAuto = True
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
Case 2 'SiO2
Sheets("QC Graph").Select
With Charts("QC Graph").Axes(xlValue)
.MinimumScale = 15
.MaximumScale = 25
.MinorUnitIsAuto = True
.MajorUnitIsAuto = True
.Crosses = xlAutomatic
.ScaleType = xlLinear
End With
End Select
ElseIf QCSection = "Water Bench" Then
Select Case SectionNumber
Case 1 To 2 'M-Alk,CaH
Sheets("QC Graph").Select
With Charts("QC Graph").Axes(xlValue)
.MinimumScale = 85
.MaximumScale = 125
.MinorUnitIsAuto = True
.MajorUnitIsAuto = True
.Crosses = xlAutomatic
.ScaleType = xlLinear
End With
Case 3 'COD
Sheets("QC Graph").Select
With Charts("QC Graph").Axes(xlValue)
.MinimumScale = 35
.MaximumScale = 65
.MinorUnitIsAuto = True
.MajorUnitIsAuto = True
.Crosses = xlAutomatic
.ScaleType = xlLinear
End With
End Select
ElseIf QCSection = "Micro Lab" Then
Select Case SectionNumber
Case 1 To 3 'HPC,TC,FC
With Charts("QC Graph").Axes(xlValue)
.MinimumScale = Auto
.MaximumScale = Auto
.MinorUnitIsAuto = True
.MajorUnitIsAuto = True
.Crosses = xlAutomatic
.ScaleType = xlLinear
End With
End Select
End If
End Sub
I have a serious problem with a chart that I made using VBA.
I get the error: Runtime error 1004:
"Unable to set the values property of the series class"
and sometimes the same error but just for the named property of the series.
The chart is a standard lines chart.
I hope somebody can help me
Below is the section of code that is flagged:
Sub ChartOptions()
' this sets up the QC Graph for the main lab with Chart title,
' axis title and scale of Y-axis according to each parameter
Sheets("Calcs").Select
ActiveCell = Cells(3, 2)
ActiveCell.Offset(1, 0).Select
ActiveCell.FormulaR1C1 = "=Ave+1*(STDEV)" ' UWL
ActiveCell.Offset(1, 0).Select
ActiveCell.FormulaR1C1 = "=Ave-1*(STDEV)" 'LWL
ActiveCell.Offset(1, 0).Select
ActiveCell.FormulaR1C1 = "=Ave+3*(STDEV)" 'UCL
ActiveCell.Offset(1, 0).Select
ActiveCell.FormulaR1C1 = "=Ave-3*(STDEV)" 'LCL
Range("B3:B7").Select
Selection.Copy
Range("C3:AZ7").Select
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
a = MsgBox("Limits data created. Click Ok to view Graph", vbOKOnly,
"Limits Data")
If a = vbOK Then
Sheets("QC Graph").Select
With Charts("QC Graph") 'this sets up the chart title, axis
title and legend
.HasTitle = True
.ChartTitle.Text = "QC Graph for:" & " " & QCType & " "
& "at the" & " " & QCSection
.SeriesCollection(1).Name = QCType
**** .SeriesCollection(1).Values = QCData *****
End With
With Charts("QC Graph").Axes(xlValue)
.HasTitle = True
.AxisTitle.Text = QCType
End With
End If
'this sets up the various QCtypes' Y-axis scales
If QCSection = "Clean Lab" Then
Select Case SectionNumber
Case 1 To 4 'Cl,SO4,Fe,Cu
Sheets("QC Graph").Select
With Charts("QC Graph").Axes(xlValue)
.MinimumScale = 5
.MaximumScale = 15
.MinorUnitIsAuto = True
.MajorUnitIsAuto = True
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
End Select
ElseIf QCSection = "Boiler Bench" Then
Select Case SectionNumber
Case 1 'Na
Sheets("QC Graph").Select
With Charts("QC Graph").Axes(xlValue)
.MinimumScale = 5
.MaximumScale = 15
.MinorUnitIsAuto = True
.MajorUnitIsAuto = True
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
Case 2 'SiO2
Sheets("QC Graph").Select
With Charts("QC Graph").Axes(xlValue)
.MinimumScale = 15
.MaximumScale = 25
.MinorUnitIsAuto = True
.MajorUnitIsAuto = True
.Crosses = xlAutomatic
.ScaleType = xlLinear
End With
End Select
ElseIf QCSection = "Water Bench" Then
Select Case SectionNumber
Case 1 To 2 'M-Alk,CaH
Sheets("QC Graph").Select
With Charts("QC Graph").Axes(xlValue)
.MinimumScale = 85
.MaximumScale = 125
.MinorUnitIsAuto = True
.MajorUnitIsAuto = True
.Crosses = xlAutomatic
.ScaleType = xlLinear
End With
Case 3 'COD
Sheets("QC Graph").Select
With Charts("QC Graph").Axes(xlValue)
.MinimumScale = 35
.MaximumScale = 65
.MinorUnitIsAuto = True
.MajorUnitIsAuto = True
.Crosses = xlAutomatic
.ScaleType = xlLinear
End With
End Select
ElseIf QCSection = "Micro Lab" Then
Select Case SectionNumber
Case 1 To 3 'HPC,TC,FC
With Charts("QC Graph").Axes(xlValue)
.MinimumScale = Auto
.MaximumScale = Auto
.MinorUnitIsAuto = True
.MajorUnitIsAuto = True
.Crosses = xlAutomatic
.ScaleType = xlLinear
End With
End Select
End If
End Sub