SQChevy
09-08-2008, 01:58 PM
Alright, I have now adjusted the method in which I am working the chart. I followed a set of code, but it is giving me an error and I can't figure out why.
I can't use a regular spreadsheet because I'm building this to be an excel add-in and want it independent of a workbook. I get the error of "Run-time error '-2147024809 (80070057)': The specified dimension is not valid for the current chart type. I'm trying to use an xyscatter plot.
I will post the code below:
With DataAOF
' .ScreenUpdating = False
For I = 2 To 5
.Cells(I, 2) = Q(I)
.Cells(I, 3) = Pwssq(I) / 10 ^ 6
Next I
For I = 1 To 5
.Cells(I + 1, 5) = Q(I)
.Cells(I + 1, 6) = LSF(I) / 10 ^ 6
.Cells(I + 1, 8) = Q(I)
.Cells(I + 1, 9) = LSFsq(I) / 10 ^ 6
Next I
.Cells(1, 2) = "Measured"
.Cells(1, 5) = "Least Squares Fit"
.Cells(1, 8) = "Laminar Flow 1/n=1"
.Cells(2, 8) = AOFc(2)
End With
With AOFChart
.Charts.Add 'Makes a new chart
.DataSource = DataAOF
With .Charts(0)
.Type = chChartTypeScatterLine
.SeriesCollection.Add 'Put in a new series
.SeriesCollection.Add
.SeriesCollection.Add
With .SeriesCollection(0)
.SetData chDimSeriesNames, 0, "B1" 'Series name is "Cole"
.SetData chDimCategories, 0, "B2:B5"
.SetData chDimValues, 0, "C2:C5"
End With
' .SeriesCollection.Add 'Make a new series
With .SeriesCollection(1)
.SetData chDimSeriesNames, 0, "E1" 'Name new series "Least Squares Fit"
.SetData chDimCategories, 0, "E2:E6" 'Set x-values to xrange
.SetData chDimValues, 0, "F2:F6" 'Set y-values to yrange
End With
' .SeriesCollection.Add 'Make a new series
With .SeriesCollection(2)
.SetData chDimSeriesNames, 0, "H1" 'Name new series "Least Squares Fit"
.SetData chDimCategories, 0, "H2:H6" 'Set x-values to xrange
.SetData chDimValues, 0, "G2:G6" 'Set y-values to yrange
End With
.HasTitle = True 'Chart has a title
' .ChartTitle.Text = "Absolute Open Flow" 'Chart title
' .Axes(xlCategory).HasTitle = True 'Allows X-Axis title
' .Axes(xlCategory).AxisTitle.Text = "Rate (Mcf/day)" 'Titles X-Axis with "Cumuulative Production"
' .Axes(xlValue).HasTitle = True 'Allows Y-Axis title
' .Axes(xlValue).AxisTitle.Text = "Pws^2=Pwf^2 (x10^6 psi^2)" 'Titles Y-Axis with "BHP/Z"
' .Legend.Position = xlLegendPositionBottom 'Moves legend to bottom
End With
'Worksheets("Spreadsheet1").Activate
.ScreenUpdating = True
End With
I can't use a regular spreadsheet because I'm building this to be an excel add-in and want it independent of a workbook. I get the error of "Run-time error '-2147024809 (80070057)': The specified dimension is not valid for the current chart type. I'm trying to use an xyscatter plot.
I will post the code below:
With DataAOF
' .ScreenUpdating = False
For I = 2 To 5
.Cells(I, 2) = Q(I)
.Cells(I, 3) = Pwssq(I) / 10 ^ 6
Next I
For I = 1 To 5
.Cells(I + 1, 5) = Q(I)
.Cells(I + 1, 6) = LSF(I) / 10 ^ 6
.Cells(I + 1, 8) = Q(I)
.Cells(I + 1, 9) = LSFsq(I) / 10 ^ 6
Next I
.Cells(1, 2) = "Measured"
.Cells(1, 5) = "Least Squares Fit"
.Cells(1, 8) = "Laminar Flow 1/n=1"
.Cells(2, 8) = AOFc(2)
End With
With AOFChart
.Charts.Add 'Makes a new chart
.DataSource = DataAOF
With .Charts(0)
.Type = chChartTypeScatterLine
.SeriesCollection.Add 'Put in a new series
.SeriesCollection.Add
.SeriesCollection.Add
With .SeriesCollection(0)
.SetData chDimSeriesNames, 0, "B1" 'Series name is "Cole"
.SetData chDimCategories, 0, "B2:B5"
.SetData chDimValues, 0, "C2:C5"
End With
' .SeriesCollection.Add 'Make a new series
With .SeriesCollection(1)
.SetData chDimSeriesNames, 0, "E1" 'Name new series "Least Squares Fit"
.SetData chDimCategories, 0, "E2:E6" 'Set x-values to xrange
.SetData chDimValues, 0, "F2:F6" 'Set y-values to yrange
End With
' .SeriesCollection.Add 'Make a new series
With .SeriesCollection(2)
.SetData chDimSeriesNames, 0, "H1" 'Name new series "Least Squares Fit"
.SetData chDimCategories, 0, "H2:H6" 'Set x-values to xrange
.SetData chDimValues, 0, "G2:G6" 'Set y-values to yrange
End With
.HasTitle = True 'Chart has a title
' .ChartTitle.Text = "Absolute Open Flow" 'Chart title
' .Axes(xlCategory).HasTitle = True 'Allows X-Axis title
' .Axes(xlCategory).AxisTitle.Text = "Rate (Mcf/day)" 'Titles X-Axis with "Cumuulative Production"
' .Axes(xlValue).HasTitle = True 'Allows Y-Axis title
' .Axes(xlValue).AxisTitle.Text = "Pws^2=Pwf^2 (x10^6 psi^2)" 'Titles Y-Axis with "BHP/Z"
' .Legend.Position = xlLegendPositionBottom 'Moves legend to bottom
End With
'Worksheets("Spreadsheet1").Activate
.ScreenUpdating = True
End With