PDA

View Full Version : Chart and Table information in Userform



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

Bob Phillips
09-08-2008, 02:14 PM
I couldn't get from this posting what you are trying to do, and what the problem was.

The code didn't help, it refers to stuff defined elsewhere in your app.

If it is just a problem of no worksheet, your addin could use a worksheet in itslef, write to that and use it there.

SQChevy
09-08-2008, 02:21 PM
Well, that is basically what I'm trying to do. The posting of data points into the embeded spreadsheet "DataAOF" works. I can see the points there when I set it to break before the error. If you look at the cell references, they correlate with the pasted locations at the beginning of the text. Let me know if this comment doesn't clear things up enough and I will post the full code, though I didn't see the need for the rest of it.

SQChevy
09-08-2008, 02:28 PM
BTW, this is a post from another forum. It is Excel Forum I cannot post the link down here yet.

SQChevy
09-08-2008, 02:45 PM
To allow me to post link...sorry

SQChevy
09-08-2008, 02:46 PM
HEre is the original thread: (please post responses here)
http://www.vbaexpress.com/forum/showthread.php?t=22074

It also posted here:
http://www.mrexcel.com/forum/showthread.php?t=340488

SQChevy
09-08-2008, 02:59 PM
Solution found please see original post.